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); }
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))); }
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); }
public static Vector3Double Negate(Vector3Double value) { Vector3Double negatedVector; negatedVector.X = -value.X; negatedVector.Y = -value.Y; negatedVector.Z = -value.Z; return(negatedVector); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public Vector3 ToVector3(Vector3Double value1) { Vector3 tmp; tmp.X = (float)value1.X; tmp.Y = (float)value1.Y; tmp.Z = (float)value1.Z; return(tmp); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public static double Dot(Vector3Double vector1, Vector3Double vector2) { return((vector1.X * vector2.X) + (vector1.Y * vector2.Y) + (vector1.Z * vector2.Z)); }
public bool Equals(Vector3Double other) { return(((X == other.X) && (Y == other.Y)) && (Z == other.Z)); }
private void YawCam(float amount) { Forward.Normalize(); Forward = (Vector3)Vector3.Transform(Forward, Matrix.RotationAxis(Up, MathUtil.DegreesToRadians(amount))); }