开发者

Data structure in C# (3.0) that represents a CUBE

开发者 https://www.devze.com 2022-12-26 21:44 出处:网络
Can you please give me some idea about how to design a data structure in C# (3.0) which will g开发者_开发知识库ive a representation of 3D data structure.

Can you please give me some idea about how to design a data structure in C# (3.0) which will g开发者_开发知识库ive a representation of 3D data structure.

I mean to say something similar to cube. Like stock data to be viewed based on time , location .

Kindly give a simple working example or even a link will do.


I doubt this is what you're looking for, but since a CUBE has three identical dimensions it can be represented with a single integer.

int CUBE = 4; // A 4x4x4 cube 

Stock data has more than three dimensions (if you must call them that) and each is unique.

Is this homework?


How about:

struct StockTickData
{
    string Symbol;
    decimal Price;
    DateTime When;
    string Where;
}

I'm not sure you really need "3D" here.


erm, well taking your question to mean one thing, I would suggest something like

class cube{
  private size;
  public set_size(value){
    if (value < 0){
      value = -value; // makes sure we have a positive size
    }
    this.size = value
  }
  public get_size(){
    return this.size;
  }
  public get_volume()
  {
    return this.size*this.size*this.size
  }
}

But you may also mean a 3D array... which is an array of arrays of arrays

Of top of my head, you might have the inner most array having three elements, representing an x,y,z value of a vertex. You would then have an array of these vertex arrays, lets say three again, which would be triangles. Then you have an array of these triangles to make an object.

Though here is a situation where object orientated programming will make it simpler to develop. Make a vertex class with thee integers and functions to control the single vertex. Then make a triangle class which has three 'vertex' properties and functions to control the triangle, such as rotating around one vertex. Then another class for an object that can have an array of triangles.

Let me know if you want me to expand or clarify any of this


Your cube needs following properties:

1) Location coordinate which is most likely vector of 3 floats describing XYZ coordinates. 2) Dimensions of your Cube, again vector of 3 floats describing height width and depth of cube 3) Orientation of your Cube, again vector of 3 floats describing yaw pitch and roll angles

Basically a 3x3 matrix is enough to represent cube.

[X Y Z] [L W D] [Y P R]

These 3 vectors are the minimum and sufficient to describe a cube in 3D space, and perform various operations on it. Operations like rotation, stretching, moving are performed using matrices. DirectX/Direct3D documentation has lots of info this kind of stuff, if this is what are you looking for. Also any basic 3D gamedev book will do.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号