Exemplo n.º 1
0
        private void UpdatePoints()
        {
            int    quater = Math.Max(SegmentsCount / 4 - 1, 1);
            double angle  = 360.0 / SegmentsCount;
            double sin    = Math.Sin(MathHelp.DegreesToRadians(-angle));
            double cos    = Math.Cos(MathHelp.DegreesToRadians(-angle));

            Point3D[,] points = new Point3D[quater, SegmentsCount + 1];
            points[0, 0]      = new Point3D(-Radius, 0, 0);
            for (int i = 1; i < quater; ++i)
            {
                double x = points[i - 1, 0].X * cos - points[i - 1, 0].Y * sin;
                double y = points[i - 1, 0].X * sin + points[i - 1, 0].Y * cos;
                points[i, 0] = new Point3D(x, y, 0);
            }
            Faces.Clear();

            for (int i = 1; i <= SegmentsCount; ++i)
            {
                for (int j = 0; j < quater; ++j)
                {
                    double x = points[j, i - 1].X * cos - points[j, i - 1].Z * sin;
                    double z = points[j, i - 1].X * sin + points[j, i - 1].Z * cos;
                    points[j, i] = new Point3D(x, points[j, i - 1].Y, z);
                    if (i > 0)
                    {
                        if (j > 0)
                        {
                            Faces.Add(new Face(new Point3D[] {
                                new Point3D(points[j - 1, i - 1].X, points[j - 1, i - 1].Y, points[j - 1, i - 1].Z),
                                new Point3D(points[j - 1, i].X, points[j - 1, i].Y, points[j - 1, i].Z),
                                new Point3D(points[j, i - 1].X, points[j, i - 1].Y, points[j, i - 1].Z)
                            }));
                            Faces.Add(new Face(new Point3D[] {
                                new Point3D(points[j, i - 1].X, points[j, i - 1].Y, points[j, i - 1].Z),
                                new Point3D(points[j, i].X, points[j, i].Y, points[j, i].Z),
                                new Point3D(points[j - 1, i].X, points[j - 1, i].Y, points[j - 1, i].Z)
                            }));
                        }
                        else if (closeBottom)
                        {
                            Faces.Add(new Face(new Point3D[] {
                                new Point3D(points[j, i - 1].X, points[j, i - 1].Y, points[j, i - 1].Z),
                                new Point3D(points[j, i].X, points[j, i].Y, points[j, i].Z),
                                new Point3D(0, 0, 0)
                            }));
                        }
                        if (j == quater - 1)
                        {
                            Faces.Add(new Face(new Point3D[] {
                                new Point3D(points[j, i - 1].X, points[j, i - 1].Y, points[j, i - 1].Z),
                                new Point3D(points[j, i].X, points[j, i].Y, points[j, i].Z),
                                new Point3D(0, Radius, 0)
                            }));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public Matrix GetGizmoModificationMatrix()
        {
            Matrix matrix = ModificationMatrix.GetIdentityMatrix(4);

            matrix = matrix.Multiply(ModificationMatrix.GetRotateXMatrix(MathHelp.DegreesToRadians(AngleX)));
            matrix = matrix.Multiply(ModificationMatrix.GetRotateYMatrix(MathHelp.DegreesToRadians(AngleY)));
            matrix = matrix.Multiply(ModificationMatrix.GetRotateZMatrix(MathHelp.DegreesToRadians(AngleZ)));
            return(matrix);
        }
Exemplo n.º 3
0
        public void RotatePositionUpDown(double angle)
        {
            Matrix rotateMatrix = ModificationMatrix.GetMoveMatrix(-Target.X, -Target.Y, -Target.Z);

            rotateMatrix = rotateMatrix.Multiply(Position.GetProjectiveCoordinates());
            Position.Set(rotateMatrix[0, 0], rotateMatrix[1, 0], rotateMatrix[2, 0]);

            angle += MathHelp.RadiansToDegrees(Position.Theta);
            angle  = Math.Min(Math.Max(angle, MIN_THETA), MAX_THETA);
            Position.SetTheta(MathHelp.DegreesToRadians(angle));
            AngleTheta = 180 - (int)angle;

            rotateMatrix = ModificationMatrix.GetMoveMatrix(Target.X, Target.Y, Target.Z);
            rotateMatrix = rotateMatrix.Multiply(Position.GetProjectiveCoordinates());
            Position.Set(rotateMatrix[0, 0], rotateMatrix[1, 0], rotateMatrix[2, 0]);
        }
Exemplo n.º 4
0
        public void RotateTargetLeftRight(double angle)
        {
            Matrix rotateMatrix = ModificationMatrix.GetMoveMatrix(-Position.X, -Position.Y, -Position.Z);

            rotateMatrix = rotateMatrix.Multiply(Target.GetProjectiveCoordinates());
            Target.Set(rotateMatrix[0, 0], rotateMatrix[1, 0], rotateMatrix[2, 0]);

            angle += MathHelp.RadiansToDegrees(Target.Phi);
            angle %= 360;
            angle  = angle < 0 ? 360 + angle : angle;

            Target.SetPhi(MathHelp.DegreesToRadians(angle));
            AnglePhi = (int)angle;

            rotateMatrix = ModificationMatrix.GetMoveMatrix(Position.X, Position.Y, Position.Z);
            rotateMatrix = rotateMatrix.Multiply(Target.GetProjectiveCoordinates());
            Target.Set(rotateMatrix[0, 0], rotateMatrix[1, 0], rotateMatrix[2, 0]);
        }
Exemplo n.º 5
0
        private void UpdatePoints()
        {
            double angle = 360.0 / SegmentsCount;
            double sin   = Math.Sin(MathHelp.DegreesToRadians(angle));
            double cos   = Math.Cos(MathHelp.DegreesToRadians(angle));

            Point3D[] points = new Point3D[SegmentsCount + 1];
            points[0] = new Point3D(-Radius, 0, 0);
            Faces.Clear();

            for (int i = 1; i <= SegmentsCount; ++i)
            {
                double x = points[i - 1].X * cos - points[i - 1].Z * sin;
                double z = points[i - 1].X * sin + points[i - 1].Z * cos;
                points[i] = new Point3D(x, 0, z);
                if (i > 0)
                {
                    Faces.Add(new Face(new Point3D[] {
                        new Point3D(points[i - 1].X, 0, points[i - 1].Z),
                        new Point3D(points[i].X, 0, points[i].Z),
                        new Point3D(0, 0, 0)
                    }));
                    Faces.Add(new Face(new Point3D[] {
                        new Point3D(points[i - 1].X, Height, points[i - 1].Z),
                        new Point3D(points[i].X, Height, points[i].Z),
                        new Point3D(0, Height, 0)
                    }));
                    Faces.Add(new Face(new Point3D[] {
                        new Point3D(points[i - 1].X, Height, points[i - 1].Z),
                        new Point3D(points[i].X, Height, points[i].Z),
                        new Point3D(points[i - 1].X, 0, points[i - 1].Z)
                    }));
                    Faces.Add(new Face(new Point3D[] {
                        new Point3D(points[i - 1].X, 0, points[i - 1].Z),
                        new Point3D(points[i].X, 0, points[i].Z),
                        new Point3D(points[i].X, Height, points[i].Z)
                    }));
                }
            }
        }
Exemplo n.º 6
0
        private void UpdatePoints()
        {
            double angle = 360.0 / SegmentsCount;
            double sin   = Math.Sin(MathHelp.DegreesToRadians(angle));
            double cos   = Math.Cos(MathHelp.DegreesToRadians(angle));

            Point3D[,,] points         = new Point3D[2, 2, SegmentsCount + 1];
            points[BOTTOM, INSIDE, 0]  = new Point3D(-BottomRadius, 0, 0);
            points[BOTTOM, OUTSIDE, 0] = new Point3D(-(BottomRadius + Thickness), 0, 0);
            points[TOP, INSIDE, 0]     = new Point3D(-TopRadius, Height, 0);
            points[TOP, OUTSIDE, 0]    = new Point3D(-(TopRadius + Thickness), Height, 0);
            Faces.Clear();

            for (int i = 1; i <= SegmentsCount; ++i)
            {
                double x = points[BOTTOM, INSIDE, i - 1].X * cos - points[BOTTOM, INSIDE, i - 1].Z * sin;
                double z = points[BOTTOM, INSIDE, i - 1].X * sin + points[BOTTOM, INSIDE, i - 1].Z * cos;
                points[BOTTOM, INSIDE, i] = new Point3D(x, 0, z);

                x = points[BOTTOM, OUTSIDE, i - 1].X * cos - points[BOTTOM, OUTSIDE, i - 1].Z * sin;
                z = points[BOTTOM, OUTSIDE, i - 1].X * sin + points[BOTTOM, OUTSIDE, i - 1].Z * cos;
                points[BOTTOM, OUTSIDE, i] = new Point3D(x, 0, z);

                x = points[TOP, INSIDE, i - 1].X * cos - points[TOP, INSIDE, i - 1].Z * sin;
                z = points[TOP, INSIDE, i - 1].X * sin + points[TOP, INSIDE, i - 1].Z * cos;
                points[TOP, INSIDE, i] = new Point3D(x, Height, z);

                x = points[TOP, OUTSIDE, i - 1].X * cos - points[TOP, OUTSIDE, i - 1].Z * sin;
                z = points[TOP, OUTSIDE, i - 1].X * sin + points[TOP, OUTSIDE, i - 1].Z * cos;
                points[TOP, OUTSIDE, i] = new Point3D(x, Height, z);

                if (i > 0)
                {
                    Faces.Add(new Face(new Point3D[] {
                        points[TOP, OUTSIDE, i - 1],
                        points[TOP, OUTSIDE, i],
                        points[BOTTOM, OUTSIDE, i - 1]
                    }));
                    Faces.Add(new Face(new Point3D[] {
                        points[BOTTOM, OUTSIDE, i - 1],
                        points[BOTTOM, OUTSIDE, i],
                        points[TOP, OUTSIDE, i]
                    }));

                    Faces.Add(new Face(new Point3D[] {
                        points[TOP, INSIDE, i - 1],
                        points[TOP, INSIDE, i],
                        points[BOTTOM, INSIDE, i - 1]
                    }));
                    Faces.Add(new Face(new Point3D[] {
                        points[BOTTOM, INSIDE, i - 1],
                        points[BOTTOM, INSIDE, i],
                        points[TOP, INSIDE, i]
                    }));

                    Faces.Add(new Face(new Point3D[] {
                        points[TOP, INSIDE, i - 1],
                        points[TOP, INSIDE, i],
                        points[TOP, OUTSIDE, i - 1]
                    }));
                    Faces.Add(new Face(new Point3D[] {
                        points[TOP, OUTSIDE, i - 1],
                        points[TOP, OUTSIDE, i],
                        points[TOP, INSIDE, i]
                    }));

                    Faces.Add(new Face(new Point3D[] {
                        points[BOTTOM, INSIDE, i - 1],
                        points[BOTTOM, INSIDE, i],
                        points[BOTTOM, OUTSIDE, i - 1]
                    }));
                    Faces.Add(new Face(new Point3D[] {
                        points[BOTTOM, OUTSIDE, i - 1],
                        points[BOTTOM, OUTSIDE, i],
                        points[BOTTOM, INSIDE, i]
                    }));
                }
            }
        }