Click here to Skip to main content
15,905,558 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

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:

C#
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[^]
 
Share this answer
 
Why not just store them in a three dimensional matrix[^]: Multidimensional Arrays (C# Programming Guide)[^].

Regards,

Manfred
 
Share this answer
 
Thanks everyone,
I solved this by using an IList<mypoint> of MyPoint and MyPoint is a class that I made which holds 3 coordinates(x,y,z)
 
Share this answer
 
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/[^]
 
Share this answer
 
v8

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900