public static Vector4 ConvertFrom(Microsoft.DirectX.Vector4 value) { return(new Vector4() { X = value.X, Y = value.Y, Z = value.Z, W = value.W }); }
public void RunTests() { Vector4 v1 = new Vector4(3, 2, 1, 0); Vector4 v2 = new Vector4(-4, 1, 2, 1); DXVec4 dx1 = new DXVec4(3, 2, 1, 0); DXVec4 dx2 = new DXVec4(-4, 1, 2, 1); TestMagnitude(v1, v2, dx1, dx2); TestNormalize(v1, v2, dx1, dx2); TestDot(v1, v2, dx1, dx2); TestAdd(v1, v2, dx1, dx2); TestSub(v1, v2, dx1, dx2); TestScale(v1, v2, dx1, dx2); TestTransform(v1, v2, dx1, dx2); PrintResults(v1, v2); }
private void TestRotations() { Vector4 v = new Vector4(1, 1, 1, 1); Quaternion q = new Quaternion(Yaw, Pitch, Roll); Vector4 r = q.RotatePt(v); DXVec4 dxv = new DXVec4(1, 1, 1, 1); DXQuat dxq = DXQuat.RotationYawPitchRoll(Yaw, Pitch, Roll); DXMatrix dxm = DXMatrix.RotationQuaternion(dxq); DXVec4 dxr = DXVec4.Transform(dxv, dxm); }
/// <summary> /// Converts a <see cref="Microsoft.DirectX.Vector4"/> to <see cref="Fusee.Math.Core.Vector4F"/>. /// </summary> /// <param name="value">The vector to convert.</param> /// <returns>A <see cref="Fusee.Math.Core.Vector4F"/> value.</returns> public static Fusee.Math.Core.Vector4F FromDirectX(Microsoft.DirectX.Vector4 value) { return(new Fusee.Math.Core.Vector4F(value.X, value.Y, value.Z, value.W)); }
private void TestMagnitude(Vector4 v1, Vector4 v2, DXVec4 dx1, DXVec4 dx2) { Magnitudes = new float[4]; Magnitudes[0] = v1.Magnitude(); Magnitudes[1] = v2.Magnitude(); Magnitudes[2] = dx1.Length(); Magnitudes[3] = dx2.Length(); MagnitudesSq = new float[4]; MagnitudesSq[0] = v1.MagnitudeS(); MagnitudesSq[1] = v2.MagnitudeS(); MagnitudesSq[2] = dx1.LengthSq(); MagnitudesSq[3] = dx2.LengthSq(); }
private void TestDot(Vector4 v1, Vector4 v2, DXVec4 dx1, DXVec4 dx2) { DotProducts = new float[2]; DotProducts[0] = Vector4.Dot(v1, v2); DotProducts[1] = DXVec4.Dot(dx1, dx2); }
private void TestAdd(Vector4 v1, Vector4 v2, DXVec4 dx1, DXVec4 dx2) { AdditionResults = new Vector4[2]; AdditionResults[0] = v1 + v2; AdditionResults[1] = DXToV3(dx1 + dx2); }
private Vector4 DXToV3(DXVec4 dxv) { return new Vector4(dxv.X, dxv.Y, dxv.Z, dxv.W); }
private void TestTransform(Vector4 v1, Vector4 v2, DXVec4 dx1, DXVec4 dx2) { TransformResults = new Vector4[4]; float rads = (float)(30 * Math.PI / 180); Vector4 axis = (new Vector4(1, 2, 3, 0)).Normalize(); Matrix4 rotation = Matrix4.RotateAxisAngle(new Vector4(1, 2, 3, 0), rads); Microsoft.DirectX.Matrix dxaxisangle = Microsoft.DirectX.Matrix.RotationAxis(new Microsoft.DirectX.Vector3(1, 2, 3), rads); DXTransformMatrix = Microsoft.DirectX.Matrix.RotationAxis(new Microsoft.DirectX.Vector3(1, 2, 3), rads); DXTransformResults = new Microsoft.DirectX.Vector4[2]; DXTransformResults[0] = DXVec4.Transform(dx1, DXTransformMatrix); DXTransformResults[1] = DXVec4.Transform(dx2, DXTransformMatrix); TransformResults[0] = v1 * rotation; TransformResults[1] = v2 * rotation; TransformResults[2] = new Vector4(DXTransformResults[0].X, DXTransformResults[0].Y, DXTransformResults[0].Z, DXTransformResults[0].W); TransformResults[3] = new Vector4(DXTransformResults[1].X, DXTransformResults[1].Y, DXTransformResults[1].Z, DXTransformResults[1].W); }
private void TestSub(Vector4 v1, Vector4 v2, DXVec4 dx1, DXVec4 dx2) { SubtractionResults = new Vector4[2]; SubtractionResults[0] = v1 - v2; SubtractionResults[1] = DXToV3(dx1 - dx2); }
private void TestScale(Vector4 v1, Vector4 v2, DXVec4 dx1, DXVec4 dx2) { ScaleResults = new Vector4[4]; ScaleResults[0] = v1 * 2.0f; ScaleResults[1] = v2 * .5f; ScaleResults[2] = DXToV3(DXVec4.Multiply(dx1, 2.0f)); ScaleResults[3] = DXToV3(DXVec4.Multiply(dx2, 0.5f)); }
private void TestNormalize(Vector4 v1, Vector4 v2, DXVec4 dx1, DXVec4 dx2) { NormResults = new Vector4[4]; NormResults[0] = (new Vector4(v1)).Normalize(); NormResults[1] = (new Vector4(v2)).Normalize(); NormResults[2] = DXToV3(DXVec4.Normalize(dx1)); NormResults[3] = DXToV3(DXVec4.Normalize(dx2)); }