Click here to Skip to main content
Sign Up to vote bad
good
See more: C#WPFarrays
Hello everyone,
I'm doing a project for my university and I'm a little lost. I want to store a set of points in order, each point has 3 coordinates (x,y,z) . I'm getting these coordinates from the depth image given by the kinect, anyway my question is: What is the best way to store these coordinates in c# and wpf ? I thought of making an array of structs but couldn't find the right way to do that so please help me fast
Thanks in advance
Posted 19 May '12 - 12:30
Makbg494


4 solutions

First of all I would not use a class, I would use a struct. This does not have to contain any strings so does not need to use the heap:
 
public struct Point3
{
    public Point3(double x, double y, double z)
    {
        X = x; Y = y; Z = z;
    }
    public double X { get; set; }
    public double Y { get; set; }
    public double Z { get; set; }
}
 
You could also use the Microsoft.XNA.Framework Vector3 which will include all the extra methods. See http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.vector3_members.aspx[^]
  Permalink  
Why not just store them in a three dimensional matrix[^]: Multidimensional Arrays (C# Programming Guide)[^].
 
Regards,
 
Manfred
  Permalink  
Thanks everyone,
I solved this by using an IList of MyPoint and MyPoint is a class that I made which holds 3 coordinates(x,y,z)
  Permalink  
1. Solution one
 
// 1) Create Coordinate class. However, you may make a struct as well.
public class Coordinate
{
public int x;
public int y;
public int z;
 
public Coordinate()
{
 
}
 
public int X
{
get { return x; }
set { this.x = value; }
}
 
public int Y
{
get { return y; }
set { this.y = value; }
}
 
public int Z
{
get { return z; }
set { this.z = value; }
}
}
 

// 2 Create instance of Coordinate List
List<coordinate> xyz = new List<coordinate>(); // see System.Collections.Generic namespace
 
// Create instance of coordinate object
Coordinate cor = new Coordinate();
 
// Then, add the points to the coordinate object
cor.X = 12;
cor.Y = 24;
cor.Z = 32;
xyz.Add(cor); // add the coordinate object to the list
// ..... add
// ..... add
// ......// Repeat this as many times

// 3) Now you hold many points in the list
 

2. Solution Two
 
You mentioned that you are getting these points (x, y, z) from a depth image. In general,
for example, if you have an image with size of 1024 x 1024, you may have many many points. In this case the solution above is not working or not working efficiently. The best way is: you may create an image with 3 layers (or three dimensional array), just like RGB images. Each layer (or band) of the RGB image holds x, y, or z points, respectively. However, we need to know the dinamic ranges of your values. You may use "PixelFormat.Format48bppRgb" image to hold these points. This image has value ranges from 0 to 65535.
You may find some usefull DLL from here:
http://www.artuxsoft.com/[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 518
1 Arun Vasu 315
2 Maciej Los 218
3 OriginalGriff 205
4 Aarti Meswania 170
0 Sergey Alexandrovich Kryukov 9,670
1 OriginalGriff 7,409
2 CPallini 3,968
3 Rohan Leuva 3,352
4 Maciej Los 2,861


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 25 May 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid