Beispiel #1
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // reduce flicker

            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.DoubleBuffer, true);

            CreateCube();

            TheCube = (ThreeDObject)((ICloneable)TheCubeOriginal).Clone();             // recopy original object
            point1  = (ThreeDPoint)((ICloneable)point1or).Clone();
            point2  = (ThreeDPoint)((ICloneable)point2or).Clone();
            timer1.Start();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            point.Scale(100);
            point.Translate(new float[] { 150, 150, 0 });
            point1.Scale(100);
            point1.Translate(new float[] { 150, 150, 0 });
            point2.Scale(100);
            point2.Translate(new float[] { 150, 150, 0 });
            createNetwork();
            point1or = (ThreeDPoint)((ICloneable)point1).Clone();
            point2or = (ThreeDPoint)((ICloneable)point2).Clone();
        }
Beispiel #2
0
 public void RotateAt(ThreeDPoint p, float angle)
 {
     for (int i = 0; i < Polygons.Count; i++)
     {
         ((ThreeDPolygon)Polygons[i]).RotateAt(p, angle);
     }
 }
Beispiel #3
0
 public void RotateAtZNegative(ThreeDPoint origin, float angle)
 {
     for (int i = 0; i < Vertices.Count; i++)
     {
         ((ThreeDPoint)Vertices[i]).RotateAtZNegative(origin, angle);
     }
 }
Beispiel #4
0
 public void RotateX(ThreeDPoint origin, float degrees)
 {
     for (int i = 0; i < Vertices.Count; i++)
     {
         ((ThreeDPoint)Vertices[i]).RotateX(origin, degrees);
     }
 }
Beispiel #5
0
        ThreeDPoint GetLeftmostPoint()
        {
            float xmin = 1000;
            float ymin = 1000;
            float zmin = 1000;

            for (int i = 0; i < Vertices.Count; i++)
            {
                ThreeDPoint nextPoint = (ThreeDPoint)Vertices[i];
                if (nextPoint.X < xmin)
                {
                    xmin = nextPoint.X;
                }
                if (nextPoint.Y < ymin)
                {
                    ymin = nextPoint.Y;
                }
                if (nextPoint.Z < zmin)
                {
                    zmin = nextPoint.Z;
                }
            }

            ThreeDPoint origin = new ThreeDPoint(xmin, ymin, zmin);

            return(origin);
        }
Beispiel #6
0
 public void RotateX(ThreeDPoint origin, float angle)
 {
     RotationMatrix.SetToXAxisRotation(angle);
     float[] result = RotationMatrix.VectorMultiply(new float[] { X - origin.X, Y - origin.Y, Z - origin.Z, 1 });
     X = result[0] + origin.X;
     Y = result[1] + origin.Y;
     Z = result[2] + origin.Z;
 }
Beispiel #7
0
 private void button3_Click(object sender, EventArgs e)
 {
     TheCube = (ThreeDObject)((ICloneable)TheCubeOriginal).Clone(); // recopy original object
     point1  = (ThreeDPoint)((ICloneable)point1or).Clone();
     point2  = (ThreeDPoint)((ICloneable)point2or).Clone();
     TheCube.SortPolygonsInZOrder();
     TheCube.RotateAtZ(TheCube.GetCenter(), AngleCount);
     point1.RotateAtZ(TheCube.GetCenter(), AngleCount);
     point2.RotateAtZ(TheCube.GetCenter(), AngleCount);
     AngleCount += 20;
     Invalidate();
 }
Beispiel #8
0
        public ThreeDPoint GetCenter()
        {
            ThreeDPoint p = new ThreeDPoint(0, 0, 0);

            for (int i = 0; i < Polygons.Count; i++)
            {
                p = p + ((ThreeDPolygon)Polygons[i]).GetCenter();
            }

            p.DivideThePoint(Polygons.Count);

            return(p);
        }
Beispiel #9
0
        public ThreeDPoint GetCenter()
        {
            ThreeDPoint p = new ThreeDPoint(0, 0, 0);

            for (int i = 0; i < Vertices.Count; i++)
            {
                p = p + (ThreeDPoint)Vertices[i];
            }

            p.DivideThePoint(Vertices.Count);

            return(p);
        }
Beispiel #10
0
        public PointF To2D(ThreeDPoint origin)
        {
            float zsmall = Z;

            if (zsmall == 0.0f)
            {
                zsmall = 1.0f;
            }
//		  PointF aPoint = new PointF(Distance * X/zsmall, Distance * Y/zsmall);
            PointF aPoint = new PointF(X * (1 - (Z / Distance)), Y * (1 - Z / Distance));

            return(aPoint);
        }
Beispiel #11
0
        private void createNetwork()
        {
            ThreeDPoint point1 = new ThreeDPoint(0, 0, 1);
            ThreeDPoint point2 = new ThreeDPoint(1, 0, 0);
            ThreeDPoint point  = new ThreeDPoint(0, 0, 0);

            point.Scale(100);
            point.Translate(new float[] { 150, 150, 0 });
            points.Add(point);
            point1.Scale(100);
            point1.Translate(new float[] { 150, 150, 0 });
            points.Add(point1);
            point2.Scale(100);
            point2.Translate(new float[] { 150, 150, 0 });
            points.Add(point2);
        }
Beispiel #12
0
        public void AddPoint(float x, float y, float z)
        {
            ThreeDPoint aPoint = new ThreeDPoint(x, y, z);

            Vertices.Add(aPoint);
        }
Beispiel #13
0
        object ICloneable.Clone()
        {
            ThreeDPoint copyObject = new ThreeDPoint(X, Y, Z);

            return(copyObject);
        }