Exemplo n.º 1
0
 public static void Transform(ref Vector3Wide v, ref Matrix3x3Wide m, out Vector3Wide result)
 {
     TransformWithoutOverlap(ref v, ref m, out var temp);
     result = temp;
 }
Exemplo n.º 2
0
        public static void TransformWithoutOverlap(ref Vector3Wide v, ref QuaternionWide rotation, out Vector3Wide result)
        {
            //This operation is an optimized-down version of v' = q * v * q^-1.
            //The expanded form would be to treat v as an 'axis only' quaternion
            //and perform standard quaternion multiplication.  Assuming q is normalized,
            //q^-1 can be replaced by a conjugation.
            var x2  = rotation.X + rotation.X;
            var y2  = rotation.Y + rotation.Y;
            var z2  = rotation.Z + rotation.Z;
            var xx2 = rotation.X * x2;
            var xy2 = rotation.X * y2;
            var xz2 = rotation.X * z2;
            var yy2 = rotation.Y * y2;
            var yz2 = rotation.Y * z2;
            var zz2 = rotation.Z * z2;
            var wx2 = rotation.W * x2;
            var wy2 = rotation.W * y2;
            var wz2 = rotation.W * z2;

            result.X = v.X * (Vector <float> .One - yy2 - zz2) + v.Y * (xy2 - wz2) + v.Z * (xz2 + wy2);
            result.Y = v.X * (xy2 + wz2) + v.Y * (Vector <float> .One - xx2 - zz2) + v.Z * (yz2 - wx2);
            result.Z = v.X * (xz2 - wy2) + v.Y * (yz2 + wx2) + v.Z * (Vector <float> .One - xx2 - yy2);
        }
Exemplo n.º 3
0
 public static void LengthSquared(ref Vector3Wide v, out Vector <float> lengthSquared)
 {
     lengthSquared = v.X * v.X + v.Y * v.Y + v.Z * v.Z;
 }
Exemplo n.º 4
0
 public static void CreateFrom(ref Vector3 source, out Vector3Wide broadcasted)
 {
     broadcasted.X = new Vector <float>(source.X);
     broadcasted.Y = new Vector <float>(source.Y);
     broadcasted.Z = new Vector <float>(source.Z);
 }
Exemplo n.º 5
0
 public static void Scale(ref Vector3Wide vector, ref Vector <float> scalar, out Vector3Wide result)
 {
     result.X = vector.X * scalar;
     result.Y = vector.Y * scalar;
     result.Z = vector.Z * scalar;
 }
Exemplo n.º 6
0
 public static void Negate(ref Vector3Wide v, out Vector3Wide result)
 {
     result.X = -v.X;
     result.Y = -v.Y;
     result.Z = -v.Z;
 }
Exemplo n.º 7
0
 public static void GetLane(ref Vector3Wide wide, int laneIndex, out Vector3 narrow)
 {
     ref var start = ref Unsafe.Add(ref Unsafe.As <Vector <float>, float>(ref wide.X), laneIndex);
Exemplo n.º 8
0
 public static void Max(ref Vector <float> s, ref Vector3Wide v, out Vector3Wide result)
 {
     result.X = Vector.Max(s, v.X);
     result.Y = Vector.Max(s, v.Y);
     result.Z = Vector.Max(s, v.Z);
 }
Exemplo n.º 9
0
 public static void Negate(ref Matrix2x3Wide m, out Matrix2x3Wide result)
 {
     Vector3Wide.Negate(ref m.X, out result.X);
     Vector3Wide.Negate(ref m.Y, out result.Y);
 }
Exemplo n.º 10
0
 public static void ConditionalSelect(ref Vector <int> condition, ref Vector3Wide left, ref Vector3Wide right, out Vector3Wide result)
 {
     result.X = Vector.ConditionalSelect(condition, left.X, right.X);
     result.Y = Vector.ConditionalSelect(condition, left.Y, right.Y);
     result.Z = Vector.ConditionalSelect(condition, left.Z, right.Z);
 }
Exemplo n.º 11
0
 public static void TransformByTransposeWithoutOverlap(ref Vector3Wide v, ref Matrix2x3Wide m, out Vector2Wide result)
 {
     result.X = v.X * m.X.X + v.Y * m.X.Y + v.Z * m.X.Z;
     result.Y = v.X * m.Y.X + v.Y * m.Y.Y + v.Z * m.Y.Z;
 }
Exemplo n.º 12
0
 public static void Add(ref Matrix2x3Wide a, ref Matrix2x3Wide b, out Matrix2x3Wide result)
 {
     Vector3Wide.Add(ref a.X, ref b.X, out result.X);
     Vector3Wide.Add(ref a.Y, ref b.Y, out result.Y);
 }
Exemplo n.º 13
0
 public static void Transform(ref Vector2Wide v, ref Matrix2x3Wide m, out Vector3Wide result)
 {
     result.X = v.X * m.X.X + v.Y * m.Y.X;
     result.Y = v.X * m.X.Y + v.Y * m.Y.Y;
     result.Z = v.X * m.X.Z + v.Y * m.Y.Z;
 }
Exemplo n.º 14
0
        public static void Transform(ref Vector3Wide v, ref QuaternionWide rotation, out Vector3Wide result)
        {
            var tempV = v;

            TransformWithoutOverlap(ref tempV, ref rotation, out result);
        }
Exemplo n.º 15
0
 public static void Add(ref Vector3Wide a, ref Vector3Wide b, out Vector3Wide result)
 {
     result.X = a.X + b.X;
     result.Y = a.Y + b.Y;
     result.Z = a.Z + b.Z;
 }
Exemplo n.º 16
0
        public static void TransformUnitXY(ref QuaternionWide rotation, out Vector3Wide x, out Vector3Wide y)
        {
            var x2  = rotation.X + rotation.X;
            var y2  = rotation.Y + rotation.Y;
            var z2  = rotation.Z + rotation.Z;
            var xx2 = rotation.X * x2;
            var xy2 = rotation.X * y2;
            var xz2 = rotation.X * z2;
            var yy2 = rotation.Y * y2;
            var yz2 = rotation.Y * z2;
            var zz2 = rotation.Z * z2;
            var wx2 = rotation.W * x2;
            var wy2 = rotation.W * y2;
            var wz2 = rotation.W * z2;

            x.X = Vector <float> .One - yy2 - zz2;
            x.Y = xy2 + wz2;
            x.Z = xz2 - wy2;
            y.X = xy2 - wz2;
            y.Y = Vector <float> .One - xx2 - zz2;
            y.Z = yz2 + wx2;
        }
Exemplo n.º 17
0
 public static void Add(ref Vector3Wide v, ref Vector <float> s, out Vector3Wide result)
 {
     result.X = v.X + s;
     result.Y = v.Y + s;
     result.Z = v.Z + s;
 }
Exemplo n.º 18
0
 public static void Max(ref Vector3Wide a, ref Vector3Wide b, out Vector3Wide result)
 {
     result.X = Vector.Max(a.X, b.X);
     result.Y = Vector.Max(a.Y, b.Y);
     result.Z = Vector.Max(a.Z, b.Z);
 }
Exemplo n.º 19
0
 public static void Subtract(ref Vector3Wide a, ref Vector3Wide b, out Vector3Wide result)
 {
     result.X = a.X - b.X;
     result.Y = a.Y - b.Y;
     result.Z = a.Z - b.Z;
 }
Exemplo n.º 20
0
 public static void Abs(ref Vector3Wide vector, out Vector3Wide result)
 {
     result.X = Vector.Abs(vector.X);
     result.Y = Vector.Abs(vector.Y);
     result.Z = Vector.Abs(vector.Z);
 }
Exemplo n.º 21
0
 public static void Subtract(ref Vector3Wide v, ref Vector <float> s, out Vector3Wide result)
 {
     result.X = v.X - s;
     result.Y = v.Y - s;
     result.Z = v.Z - s;
 }
Exemplo n.º 22
0
 public static void Cross(ref Vector3Wide a, ref Vector3Wide b, out Vector3Wide result)
 {
     CrossWithoutOverlap(ref a, ref b, out var temp);
     result = temp;
 }
Exemplo n.º 23
0
 public static void Subtract(ref Vector <float> s, ref Vector3Wide v, out Vector3Wide result)
 {
     result.X = s - v.X;
     result.Y = s - v.Y;
     result.Z = s - v.Z;
 }
Exemplo n.º 24
0
 public static void Length(ref Vector3Wide v, out Vector <float> length)
 {
     length = Vector.SquareRoot(v.X * v.X + v.Y * v.Y + v.Z * v.Z);
 }
Exemplo n.º 25
0
 public static void Dot(ref Vector3Wide a, ref Vector3Wide b, out Vector <float> result)
 {
     result = a.X * b.X + a.Y * b.Y + a.Z * b.Z;
 }
Exemplo n.º 26
0
 public static void Distance(ref Vector3Wide a, ref Vector3Wide b, out Vector <float> distance)
 {
     Subtract(ref b, ref a, out var offset);
     Length(ref offset, out distance);
 }
Exemplo n.º 27
0
 public static void TransformWithoutOverlap(ref Vector3Wide v, ref Matrix3x3Wide m, out Vector3Wide result)
 {
     result.X = v.X * m.X.X + v.Y * m.Y.X + v.Z * m.Z.X;
     result.Y = v.X * m.X.Y + v.Y * m.Y.Y + v.Z * m.Z.Y;
     result.Z = v.X * m.X.Z + v.Y * m.Y.Z + v.Z * m.Z.Z;
 }