private static Matrix <float> ComputeViewMatrix(Vector <float> eye, Vector <float> target, Vector <float> up) { Code.AssertArgNonNull(eye, "eye"); Code.AssertArgNonNull(target, "target"); Code.AssertArgNonNull(up, "up"); Code.Assert <ArgumentException>(eye.Dimensions == 3, "The eye vector must be 3 dimensional."); Code.Assert <ArgumentException>(target.Dimensions == 3, "The target vector must be 3 dimensional."); Code.Assert <ArgumentException>(up.Dimensions == 3, "The up vector must be 3 dimensional."); Vector <float> z = Vector <float> .Normalize(eye - target); Vector <float> x = Vector <float> .Normalize(Vector <float> .CrossProduct(up, z)); Vector <float> y = Vector <float> .Normalize(Vector <float> .CrossProduct(z, x)); Matrix <float> result = new Matrix <float>(new float[, ] { { x.X, y.X, z.X, 0 }, { x.Y, y.Y, z.Y, 0 }, { x.Z, y.Z, z.Z, 0 }, { -((x.X * eye.X) + (x.Y * eye.Y) + (x.Z * eye.Z)), -((y.X * eye.X) + (y.Y * eye.Y) + (y.Z * eye.Z)), -((z.X * eye.X) + (z.Y * eye.Y) + (z.Z * eye.Z)), 1 }, }); return(result); }
public Sphere(Vector <T> position, Quaternion <T> orientation, T radius) { Code.Assert <ArgumentException>(position.Dimensions == 3, "The position vector privided was not 3 dimensional."); this._position = position; this._orientation = orientation; this._radius = radius; }
public Cube(T halfLength, Vector <T> position, Quaternion <T> orientation) { Code.Assert <ArgumentException>(position.Dimensions == 3, "The position vector privided was not 3 dimensional."); this._halfLength = halfLength; this._position = position; this._orientation = orientation; }
public void Run(float timeStep) { Code.Assert <System.ArgumentException>(timeStep >= 0, "The timestep can't be negative."); if (timeStep == 0.0f) { return; } }