Example #1
0
 public void Translate(Vector3D translationVector)
 {
     for (int i = 0; i < this.vertices.Count; i++)
     {
         this.vertices[i] += translationVector;
     }
 }
Example #2
0
        public static Vector3D CrossProduct(Vector3D a, Vector3D b)
        {
            double crossX = a.Y * b.Z - a.Z * b.Y;
            double crossY = a.Z * b.X - a.X * b.Z;
            double crossZ = a.X * b.Y - a.Y * b.X;

            return new Vector3D(crossX, crossY, crossZ);
        }
Example #3
0
        public void Scale(Vector3D scaleCenter, double scaleFactor)
        {
            for (int i = 0; i < this.vertices.Count; i++)
            {
                Vector3D centeredCurrent = this.vertices[i] - scaleCenter;

                Vector3D scaledCenteredCurrent = centeredCurrent * scaleFactor;

                this.vertices[i] = scaledCenteredCurrent + scaleCenter;
            }
        }
Example #4
0
        public virtual Vector3D GetCenter()
        {
            Vector3D verticesSum = new Vector3D(0, 0, 0);

            for (int i = 0; i < this.vertices.Count; i++)
            {
                verticesSum += this.vertices[i];
            }

            return verticesSum / this.vertices.Count;
        }
Example #5
0
        public void RotateInXY(Vector3D rotCenter, double angleDegrees)
        {
            for (int i = 0; i < this.vertices.Count; i++)
            {
                Vector3D centeredCurrent = this.vertices[i] - rotCenter;

                double angleRads = angleDegrees * Math.PI / 180.0;

                Vector3D rotatedCenteredCurrent = new Vector3D(
                    centeredCurrent.X * Math.Cos(angleRads) - centeredCurrent.Y * Math.Sin(angleRads),
                    centeredCurrent.X * Math.Sin(angleRads) + centeredCurrent.Y * Math.Cos(angleRads),
                    centeredCurrent.Z);

                this.vertices[i] = rotatedCenteredCurrent + rotCenter;
            }
        }
Example #6
0
 public Circle(Vector3D center, double radius)
     : base(center)
 {
     this.Radius = radius;
 }
Example #7
0
        public static double DotProduct(Vector3D a, Vector3D b)
        {
            double result = 0;
            for (int d = 0; d < 3; d++)
            {
                result += a[d] * b[d];
            }

            return result;
        }
Example #8
0
 public static double GetAngleDegrees(Vector3D a, Vector3D b)
 {
     return Math.Acos(Vector3D.DotProduct(a, b) / a.Magnitude * b.Magnitude);
 }
Example #9
0
 public Cylinder(Vector3D top, Vector3D bottom, double radius)
     : base(top, bottom)
 {
     this.Radius = radius;
 }
Example #10
0
 public Triangle(Vector3D a, Vector3D b, Vector3D c)
     : base(a, b, c)
 {
 }