我知道有一个二维坐标的类,但是怎么样也没办法做到三维坐标,求大佬解答

解决方案 »

  1.   

    public class ThreeDimensional

          public double X{get;set;}
          public double Y{get;set;}
          public double Z{get;set;}

    多简单粗暴
      

  2.   

    使用C#和微软的托管D3D开发,数据资源来源于互联网高程是使用GDAL库读取自TIFF文件读取TIFF源码下载  https://download.csdn.net/download/mosangbike/6667651C#图形图像技术交流群 
      

  3.   

    arr[][] 就成
      

  4.   

    float[][][] axis = new float[][][] {}
      

  5.   

    举例立方体操作的定义using System;public class Math3D
    {
        public class Point3D
        {
            public double X;
            public double Y;
            public double Z;         public Point3D(int x, int y, int z)
            {
                X = x;
                Y = y;
                Z = z;    // 例子里设置为1了
            }        public Point3D(float x, float y, float z)
            {
                X = (double)x;
                Y = (double)y;
                Z = (double)z;
            }        public Point3D(double x, double y, double z)
            {
                X = x;
                Y = y;
                Z = z;
            }        public Point3D()
            {
            }        public override string ToString()
            {
                return "(" + X.ToString() + ", " + Y.ToString() + ", " + Z.ToString() + ")";
            }
        }    public class Camera
        {
            public Point3D Position = new Point3D();
        }    public static Point3D RotateX(Point3D point3D, double degrees)
        {
            double cDegrees = (Math.PI * degrees) / 180.0f;
            double cosDegrees = Math.Cos(cDegrees);
            double sinDegrees = Math.Sin(cDegrees);
            double y = (point3D.Y * cosDegrees) + (point3D.Z * sinDegrees);
            double z = (point3D.Y * -sinDegrees) + (point3D.Z * cosDegrees);
            return new Point3D(point3D.X, y, z);
        }    public static Point3D RotateY(Point3D point3D, double degrees)
        {
            double cDegrees = (Math.PI * degrees) / 180.0;
            double cosDegrees = Math.Cos(cDegrees);
            double sinDegrees = Math.Sin(cDegrees);
            double x = (point3D.X * cosDegrees) + (point3D.Z * sinDegrees);
            double z = (point3D.X * -sinDegrees) + (point3D.Z * cosDegrees);
            return new Point3D(x, point3D.Y, z);
        }    public static Point3D RotateZ(Point3D point3D, double degrees)
        {
            double cDegrees = (Math.PI * degrees) / 180.0;
            double cosDegrees = Math.Cos(cDegrees);
            double sinDegrees = Math.Sin(cDegrees);
            double x = (point3D.X * cosDegrees) + (point3D.Y * sinDegrees);
            double y = (point3D.X * -sinDegrees) + (point3D.Y * cosDegrees);
            return new Point3D(x, y, point3D.Z);
        }    public static Point3D Translate(Point3D points3D, Point3D oldOrigin, Point3D newOrigin)
        {
            Point3D difference = new Point3D(newOrigin.X - oldOrigin.X, newOrigin.Y - oldOrigin.Y, newOrigin.Z - oldOrigin.Z);
            points3D.X += difference.X;
            points3D.Y += difference.Y;
            points3D.Z += difference.Z;
            return points3D;
        }    public static Point3D[] RotateX(Point3D[] points3D, double degrees)
        {
            for (int i = 0; i < points3D.Length; i++)
            {
                points3D[i] = RotateX(points3D[i], degrees);
            }
            return points3D;
        }    public static Point3D[] RotateY(Point3D[] points3D, double degrees)
        {
            for (int i = 0; i < points3D.Length; i++)
            {
                points3D[i] = RotateY(points3D[i], degrees);
            }
            return points3D;
        }    public static Point3D[] RotateZ(Point3D[] points3D, double degrees)
        {
            for (int i = 0; i < points3D.Length; i++)
            {
                points3D[i] = RotateZ(points3D[i], degrees);
            }
            return points3D;
        }    public static Point3D[] Translate(Point3D[] points3D, Point3D oldOrigin, Point3D newOrigin)
        {
            for (int i = 0; i < points3D.Length; i++)
            {
                points3D[i] = Translate(points3D[i], oldOrigin, newOrigin);
            }
            return points3D;
        }}
    宽度为1的例子 https://pan.baidu.com/s/1rDjOj-_OC6W0v8iaMl_jNQ
      

  6.   

    arr[][] 就成double[][] matix=new double[][]{{x1,y1,z1},{x2,y2,z3}}
      

  7.   


    非常感谢,总体思想就是new一个新的类来存储xyz三个坐标咯
      

  8.   


    可以是可以,但是这个点位比较多,我希望把他做到可视化,就好比这个点,是结束点,EndPoint(1,2,3)这种
      

  9.   

     public struct P3d{ public double x; public double y; public double z;} 
      

  10.   


    可以是可以,但是这个点位比较多,我希望把他做到可视化,就好比这个点,是结束点,EndPoint(1,2,3)这种结束点这个要求是逻辑要求,不是数据结构要求(数据结构上多维数组。或者一维多向量对象,或者一维元组)。所以这种要求你就得按楼上那些做法,定义对象(无论是结构体,还是class),当然 
    new EndPoint(1,2,3) 无非是构造。ps:这种东西在数据结构上怎么选都可以,比如C++,python的最可能的选择是vector向量,因为这个内存是连续的,访问快
      

  11.   

    微软也提供了3d向量对象(vector3d),不过这东西就不在常用命名空间里面了,属于比较专用的东西https://docs.microsoft.com/zh-cn/dotnet/api/system.windows.media.media3d.vector3d?redirectedfrom=MSDN&view=netframework-4.8
      

  12.   

    我帮你在 LinqPad 上写了一个测试程序,你参考一下吧