示例#1
0
        public static Vector3Double Clamp(Vector3Double value, Vector3Double min, Vector3Double max)
        {
            double x = value.X;

            x = (x > max.X) ? max.X : x;
            x = (x < min.X) ? min.X : x;

            double y = value.Y;

            y = (y > max.Y) ? max.Y : y;
            y = (y < min.Y) ? min.Y : y;

            double z = value.Z;

            z = (z > max.Z) ? max.Z : z;
            z = (z < min.Z) ? min.Z : z;

            Vector3Double clampedVector;

            clampedVector.X = x;
            clampedVector.Y = y;
            clampedVector.Z = z;

            return(clampedVector);
        }
示例#2
0
        private void PitchCam(float amount)
        {
            Forward.Normalize();
            Vector3 left = Vector3.Cross(Up, Forward);

            Forward = (Vector3)Vector3.Transform(Forward, Matrix.RotationAxis(left, MathUtil.DegreesToRadians(amount)));
            Up      = (Vector3)Vector3.Transform(Up, Matrix.RotationAxis(left, MathUtil.DegreesToRadians(amount)));
        }
示例#3
0
        public static double DistanceSquared(Vector3Double value1, Vector3Double value2)
        {
            double xDistance       = value1.X - value2.X;
            double yDistance       = value1.Y - value2.Y;
            double zDistance       = value1.Z - value2.Z;
            double distanceSquared = ((xDistance * xDistance) + (yDistance * yDistance)) + (zDistance * zDistance);

            return(distanceSquared);
        }
示例#4
0
        public static Vector3Double Negate(Vector3Double value)
        {
            Vector3Double negatedVector;

            negatedVector.X = -value.X;
            negatedVector.Y = -value.Y;
            negatedVector.Z = -value.Z;

            return(negatedVector);
        }
示例#5
0
        public static Vector3Double Cross(Vector3Double vector1, Vector3Double vector2)
        {
            Vector3Double product;

            product.X = (vector1.Y * vector2.Z) - (vector1.Z * vector2.Y);
            product.Y = (vector1.Z * vector2.X) - (vector1.X * vector2.Z);
            product.Z = (vector1.X * vector2.Y) - (vector1.Y * vector2.X);

            return(product);
        }
示例#6
0
        public static Vector3Double Multiply(Vector3Double value1, Vector3Double value2)
        {
            Vector3Double product;

            product.X = value1.X * value2.X;
            product.Y = value1.Y * value2.Y;
            product.Z = value1.Z * value2.Z;

            return(product);
        }
示例#7
0
        public static Vector3Double Multiply(Vector3Double value1, double scaleFactor)
        {
            Vector3Double product;

            product.X = value1.X * scaleFactor;
            product.Y = value1.Y * scaleFactor;
            product.Z = value1.Z * scaleFactor;

            return(product);
        }
示例#8
0
        public static Vector3Double Divide(Vector3Double value1, Vector3Double value2)
        {
            Vector3Double quotient;

            quotient.X = value1.X / value2.X;
            quotient.Y = value1.Y / value2.Y;
            quotient.Z = value1.Z / value2.Z;

            return(quotient);
        }
示例#9
0
        public static Vector3Double Max(Vector3Double value1, Vector3Double value2)
        {
            Vector3Double maximumVector;

            maximumVector.X = (value1.X > value2.X) ? value1.X : value2.X;
            maximumVector.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y;
            maximumVector.Z = (value1.Z > value2.Z) ? value1.Z : value2.Z;

            return(maximumVector);
        }
示例#10
0
        public static Vector3Double Min(Vector3Double value1, Vector3Double value2)
        {
            Vector3Double minimumVector;

            minimumVector.X = (value1.X < value2.X) ? value1.X : value2.X;
            minimumVector.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y;
            minimumVector.Z = (value1.Z < value2.Z) ? value1.Z : value2.Z;

            return(minimumVector);
        }
示例#11
0
        public static Vector3Double Add(Vector3Double value1, Vector3Double value2)
        {
            Vector3Double sum;

            sum.X = value1.X + value2.X;
            sum.Y = value1.Y + value2.Y;
            sum.Z = value1.Z + value2.Z;

            return(sum);
        }
示例#12
0
        public static Vector3Double Subtract(Vector3Double value1, Vector3Double value2)
        {
            Vector3Double difference;

            difference.X = value1.X - value2.X;
            difference.Y = value1.Y - value2.Y;
            difference.Z = value1.Z - value2.Z;

            return(difference);
        }
示例#13
0
        public static Vector3Double Barycentric(Vector3Double value1, Vector3Double value2, Vector3Double value3, double amount1, double amount2)
        {
            Vector3Double coordinates;

            coordinates.X = value1.X + (amount1 * (value2.X - value1.X)) + (amount2 * (value3.X - value1.X));
            coordinates.Y = value1.Y + (amount1 * (value2.Y - value1.Y)) + (amount2 * (value3.Y - value1.Y));
            coordinates.Z = value1.Z + (amount1 * (value2.Z - value1.Z)) + (amount2 * (value3.Z - value1.Z));

            return(coordinates);
        }
示例#14
0
        public Vector3 ToVector3(Vector3Double value1)
        {
            Vector3 tmp;

            tmp.X = (float)value1.X;
            tmp.Y = (float)value1.Y;
            tmp.Z = (float)value1.Z;

            return(tmp);
        }
示例#15
0
        public static Vector3Double Lerp(Vector3Double value1, Vector3Double value2, double amount)
        {
            Vector3Double lerpedVector;

            lerpedVector.X = value1.X + (value2.X - value1.X) * amount;
            lerpedVector.Y = value1.Y + (value2.Y - value1.Y) * amount;
            lerpedVector.Z = value1.Z + (value2.Z - value1.Z) * amount;

            return(lerpedVector);
        }
示例#16
0
        public static Vector3Double CatmullRom(Vector3Double value1, Vector3Double value2, Vector3Double value3, Vector3Double value4, double amount)
        {
            double amountSquared = amount * amount;
            double amountCubed   = amount * amountSquared;

            Vector3Double interpolatedVector;

            interpolatedVector.X = 0.5 * ((((2.0 * value2.X) + ((-value1.X + value3.X) * amount)) + (((((2.0 * value1.X) - (5.0 * value2.X)) + (4.0 * value3.X)) - value4.X) * amountSquared)) + ((((-value1.X + (3.0 * value2.X)) - (3.0 * value3.X)) + value4.X) * amountCubed));
            interpolatedVector.Y = 0.5 * ((((2.0 * value2.Y) + ((-value1.Y + value3.Y) * amount)) + (((((2.0 * value1.Y) - (5.0 * value2.Y)) + (4.0 * value3.Y)) - value4.Y) * amountSquared)) + ((((-value1.Y + (3.0 * value2.Y)) - (3.0 * value3.Y)) + value4.Y) * amountCubed));
            interpolatedVector.Z = 0.5 * ((((2.0 * value2.Z) + ((-value1.Z + value3.Z) * amount)) + (((((2.0 * value1.Z) - (5.0 * value2.Z)) + (4.0 * value3.Z)) - value4.Z) * amountSquared)) + ((((-value1.Z + (3.0 * value2.Z)) - (3.0 * value3.Z)) + value4.Z) * amountCubed));
            return(interpolatedVector);
        }
示例#17
0
        public static Vector3Double Normalize(Vector3Double value)
        {
            Vector3Double normalizedVector;
            double        lengthSquared    = (value.X * value.X) + (value.Y * value.Y) + (value.Z * value.Z);
            double        lengthReciprocal = 1.0 / Math.Sqrt(lengthSquared);

            normalizedVector.X = value.X * lengthReciprocal;
            normalizedVector.Y = value.Y * lengthReciprocal;
            normalizedVector.Z = value.Z * lengthReciprocal;

            return(normalizedVector);
        }
示例#18
0
        public static Vector3Double Reflect(Vector3Double vector, Vector3Double normal)
        {
            double reflection = ((vector.X * normal.X) + (vector.Y * normal.Y)) + (vector.Z * normal.Z);

            Vector3Double reflectedVector;

            reflectedVector.X = vector.X - ((2.0 * reflection) * normal.X);
            reflectedVector.Y = vector.Y - ((2.0 * reflection) * normal.Y);
            reflectedVector.Z = vector.Z - ((2.0 * reflection) * normal.Z);

            return(reflectedVector);
        }
示例#19
0
        public static Vector3Double Divide(Vector3Double value1, double value2)
        {
            double reciprocal = 1.0 / value2;

            Vector3Double quotient;

            quotient.X = value1.X * reciprocal;
            quotient.Y = value1.Y * reciprocal;
            quotient.Z = value1.Z * reciprocal;

            return(quotient);
        }
示例#20
0
        public static Vector3Double TransformNormal(Vector3Double normal, Matrix matrix)
        {
            double x = ((normal.X * matrix.M11) + (normal.Y * matrix.M21)) + (normal.Z * matrix.M31);
            double y = ((normal.X * matrix.M12) + (normal.Y * matrix.M22)) + (normal.Z * matrix.M32);
            double z = ((normal.X * matrix.M13) + (normal.Y * matrix.M23)) + (normal.Z * matrix.M33);

            Vector3Double transformedVector;

            transformedVector.X = x;
            transformedVector.Y = y;
            transformedVector.Z = z;
            return(transformedVector);
        }
示例#21
0
        public static Vector3Double SmoothStep(Vector3Double value1, Vector3Double value2, double amount)
        {
            amount = (amount > 1.0) ? 1.0 : ((amount < 0.0) ? 0.0 : amount);
            amount = (amount * amount) * (3.0 - (2.0 * amount));

            Vector3Double steppedVector;

            steppedVector.X = value1.X + ((value2.X - value1.X) * amount);
            steppedVector.Y = value1.Y + ((value2.Y - value1.Y) * amount);
            steppedVector.Z = value1.Z + ((value2.Z - value1.Z) * amount);

            return(steppedVector);
        }
示例#22
0
 static Vector3Double()
 {
     Zero     = new Vector3Double();
     One      = new Vector3Double(1f, 1f, 1f);
     UnitX    = new Vector3Double(1f, 0f, 0f);
     UnitY    = new Vector3Double(0f, 1f, 0f);
     UnitZ    = new Vector3Double(0f, 0f, 1f);
     Up       = new Vector3Double(0f, 1f, 0f);
     Down     = new Vector3Double(0f, -1f, 0f);
     Right    = new Vector3Double(1f, 0f, 0f);
     Left     = new Vector3Double(-1f, 0f, 0f);
     Forward  = new Vector3Double(0f, 0f, -1f);
     Backward = new Vector3Double(0f, 0f, 1f);
 }
示例#23
0
        public static Vector3Double Transform(Vector3Double position, Matrix matrix)
        {
            double x = (((position.X * matrix.M11) + (position.Y * matrix.M21)) + (position.Z * matrix.M31)) + matrix.M41;
            double y = (((position.X * matrix.M12) + (position.Y * matrix.M22)) + (position.Z * matrix.M32)) + matrix.M42;
            double z = (((position.X * matrix.M13) + (position.Y * matrix.M23)) + (position.Z * matrix.M33)) + matrix.M43;

            Vector3Double transformedVector;

            transformedVector.X = x;
            transformedVector.Y = y;
            transformedVector.Z = z;

            return(transformedVector);
        }
示例#24
0
        public static Vector3Double Hermite(Vector3Double value1, Vector3Double tangent1, Vector3Double value2, Vector3Double tangent2, double amount)
        {
            double amountSquared = amount * amount;
            double amountCubed   = amount * amountSquared;
            double basis1        = (2.0 * amountCubed) - (3.0 * amountSquared) + 1.0;
            double basis2        = (-2.0 * amountCubed) + (3.0 * amountSquared);
            double basis3        = amountCubed - (2.0 * amountSquared) + amount;
            double basis4        = amountCubed - amountSquared;

            Vector3Double interpolatedVector;

            interpolatedVector.X = (((value1.X * basis1) + (value2.X * basis2)) + (tangent1.X * basis3)) + (tangent2.X * basis4);
            interpolatedVector.Y = (((value1.Y * basis1) + (value2.Y * basis2)) + (tangent1.Y * basis3)) + (tangent2.Y * basis4);
            interpolatedVector.Z = (((value1.Z * basis1) + (value2.Z * basis2)) + (tangent1.Z * basis3)) + (tangent2.Z * basis4);

            return(interpolatedVector);
        }
示例#25
0
        public SpaceCam(Vector3 Position, bool HandleInput, GraphicsDevice device, float speed)
        {
            this.device = device;
            //   BBHeight = device.PresentationParameters.BackBufferHeight;

            GeneratePerspectiveProjectionMatrix(MathUtil.PiOverFour, device);

            this.Position = Position;

            Up      = Vector3.Up;
            Forward = Vector3.ForwardLH;

            SetHandleInput(HandleInput);

            this.speed = speed;

            Frustum = new BoundingFrustum(View * Projection);
        }
示例#26
0
 public static double Dot(Vector3Double vector1, Vector3Double vector2)
 {
     return((vector1.X * vector2.X) + (vector1.Y * vector2.Y) + (vector1.Z * vector2.Z));
 }
示例#27
0
 public bool Equals(Vector3Double other)
 {
     return(((X == other.X) && (Y == other.Y)) && (Z == other.Z));
 }
示例#28
0
 private void YawCam(float amount)
 {
     Forward.Normalize();
     Forward = (Vector3)Vector3.Transform(Forward, Matrix.RotationAxis(Up, MathUtil.DegreesToRadians(amount)));
 }