public PerspectiveCamera(Point3D position,
                          Vector3D lookDirection,
                          Vector3D upDirection,
                          double fieldOfView, Viewport3D viewport)
 {
     this.Position = position;
     this.LookDirection = lookDirection;
     this.UpDirection = upDirection;
     this.FieldOfView = fieldOfView;
     this.Viewport = viewport;
 }
示例#2
0
 public Quaternion(Vector3D axisOfRotation, double angleInRadians)
 {
     double halfAngleInRadians = (angleInRadians * 0.5);
     this.isNotDefaultQuaternion = true;
     axisOfRotation.Normalize();
     this.x = axisOfRotation.X * System.Math.Sin(halfAngleInRadians);
     this.y = axisOfRotation.Y * System.Math.Sin(halfAngleInRadians);
     this.z = axisOfRotation.Z * System.Math.Sin(halfAngleInRadians);
     this.w = System.Math.Cos(halfAngleInRadians);
     this.value = Matrix3D.Identity;
     this.valueIsDirty = true;
 }
示例#3
0
 public void Scale(Vector3D v)
 {
     if (!this.isNotDefaultMatrix) {
         this.m11 = v.X;
         this.m22 = v.Y;
         this.m33 = v.Z;
         this.m44 = 1;
         this.isNotDefaultMatrix = true;
     }
     else {
         this.m11 *= v.X;
         this.m12 *= v.Y;
         this.m13 *= v.Z;
         this.m21 *= v.X;
         this.m22 *= v.Y;
         this.m23 *= v.Z;
         this.m31 *= v.X;
         this.m32 *= v.Y;
         this.m33 *= v.Z;
         this.offsetX *= v.X;
         this.offsetY *= v.Y;
         this.offsetZ *= v.Z;
     }
 }
示例#4
0
 public static Point3D Subtract(Point3D p, Vector3D v)
 {
     return new Point3D(p.X - v.X, p.Y - v.Y, p.Z - v.Z);
 }
示例#5
0
 public static Point3D Add(Point3D point, Vector3D v)
 {
     return new Point3D(point.X + v.X, point.Y + v.Y, point.Z + v.Z);
 }
示例#6
0
 public static Vector3D Add(Vector3D v1, Vector3D v2)
 {
     return new Vector3D(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
 }
示例#7
0
 public static Point3D Subtract(Vector3D v, Point3D p)
 {
     return new Point3D(v.X - p.X, v.Y - p.Y, v.Z - p.Z);
 }
示例#8
0
        /// <summary>
        /// Multiples the vector by the matrix i.e. v * m
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public Vector3D Transform(Vector3D v)
        {
            if (!this.isNotDefaultMatrix) {
                return v;
            }

            return new Vector3D(v.X * this.m11 + v.Y * this.m21 + v.Z * this.m31,
                                v.X * this.m12 + v.Y * this.m22 + v.Z * this.m32,
                                v.X * this.m13 + v.Y * this.m23 + v.Z * this.m33);
        }
示例#9
0
        public static bool Equals(Vector3D v1, Vector3D v2)
        {
            if (((object)v1 == null) && ((object) v2 == null)) {
                return true;
            }
            if (((object)v1 == null) || ((object) v2 == null)) {
                return false;
            }

            return v1.X.Equals(v2.X) &&
                   v1.Y.Equals(v2.Y) &&
                   v1.Z.Equals(v2.Z);
        }
示例#10
0
 public static Vector3D Multiply(Vector3D v, double scalar)
 {
     return new Vector3D(v.X * scalar, v.Y * scalar, v.Z * scalar);
 }
示例#11
0
 public static double DotProduct(Vector3D v1, Vector3D v2)
 {
     return v1.X * v2.X + v1.Y * v2.Y + v1.Z * v2.Z;
 }
示例#12
0
 public static Vector3D Divide(Vector3D v, double scalar)
 {
     double div = 1.0 / scalar;
     return new Vector3D(v.X * div, v.Y * div, v.Z * div);
 }
示例#13
0
 public static Vector3D CrossProduct(Vector3D v1, Vector3D v2)
 {
     return new Vector3D(v1.Y * v2.Z - v1.Z * v2.Y,
                         v1.Z * v2.X - v1.X * v2.Z,
                         v1.X * v2.Y - v1.Y * v2.X);
 }
示例#14
0
        public void ScaleAt(Vector3D scale, Point3D center)
        {
            if (!this.isNotDefaultMatrix) {
                //Simple case
                this.m11 = scale.X;
                this.m22 = scale.Y;
                this.m33 = scale.Z;
                this.m44 = 1.0;
                this.offsetX = center.X - (center.X * scale.X);
                this.offsetY = center.Y - (center.Y * scale.Y);
                this.offsetZ = center.Z - (center.Z * scale.Z);
                this.isNotDefaultMatrix = true;
            }
            else {
                //Need to multiple the current matrix with the scaling matrix
                this.m11 = this.m11 * scale.X + this.m14 * center.X - this.m14 * scale.X * center.X;
                this.m12 = this.m12 * scale.Y + this.m14 * center.Y - this.m14 * scale.Y * center.Y;
                this.m13 = this.m13 * scale.Z + this.m14 * center.Z - this.m14 * scale.Z * center.Z;

                this.m21 = this.m21 * scale.X + this.m24 * center.X - this.m24 * scale.X * center.X;
                this.m22 = this.m22 * scale.Y + this.m24 * center.Y - this.m24 * scale.Y * center.Y;
                this.m23 = this.m23 * scale.Z + this.m24 * center.Z - this.m24 * scale.Z * center.Z;

                this.m31 = this.m31 * scale.X + this.m34 * center.X - this.m34 * scale.X * center.X;
                this.m32 = this.m32 * scale.Y + this.m34 * center.Y - this.m34 * scale.Y * center.Y;
                this.m33 = this.m33 * scale.Z + this.m34 * center.Z - this.m34 * scale.Z * center.Z;

                this.offsetX = this.offsetX * scale.X + this.m44 * center.X - this.m44 * scale.X * center.X;
                this.offsetY = this.offsetY * scale.Y + this.m44 * center.Y - this.m44 * scale.Y * center.Y;
                this.offsetZ = this.offsetZ * scale.Z + this.m44 * center.Z - this.m44 * scale.Z * center.Z;
            }
        }
示例#15
0
 public static Vector3D Subtract(Vector3D v1, Vector3D v2)
 {
     return new Vector3D(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);
 }
示例#16
0
 public void ScalePrepend(Vector3D v)
 {
     if (!this.isNotDefaultMatrix) {
         this.m11 = v.X;
         this.m22 = v.Y;
         this.m33 = v.Z;
         this.m44 = 1;
         this.isNotDefaultMatrix = true;
     }
     else {
         this.m11 *= v.X;
         this.m21 *= v.Y;
         this.m31 *= v.Z;
         this.m12 *= v.X;
         this.m22 *= v.Y;
         this.m32 *= v.Z;
         this.m13 *= v.X;
         this.m23 *= v.Y;
         this.m33 *= v.Z;
         this.m14 *= v.X;
         this.m24 *= v.Y;
         this.m34 *= v.Z;
     }
 }
示例#17
0
 public bool Equals(Vector3D v)
 {
     return Equals(this, v);
 }
 public NormalizedAxisAngleRotation3D(Vector3D normalizedAxis, double angleInRadians)
 {
     this.NormalizedAxis = normalizedAxis;
     this.AngleRad = angleInRadians;
 }
示例#19
0
 public static Point3D Add(Vector3D v, Point3D p)
 {
     return new Point3D(v.X + p.X, v.Y + p.Y, v.Z + p.Z);
 }