Esempio n. 1
0
        public SCNQuaternion(ref Matrix3 matrix)
        {
            double scale = System.Math.Pow(matrix.Determinant, 1.0d / 3.0d);
            float  x, y, z;

            w = (float)(System.Math.Sqrt(System.Math.Max(0, scale + matrix[0, 0] + matrix[1, 1] + matrix[2, 2])) / 2);
            x = (float)(System.Math.Sqrt(System.Math.Max(0, scale + matrix[0, 0] - matrix[1, 1] - matrix[2, 2])) / 2);
            y = (float)(System.Math.Sqrt(System.Math.Max(0, scale - matrix[0, 0] + matrix[1, 1] - matrix[2, 2])) / 2);
            z = (float)(System.Math.Sqrt(System.Math.Max(0, scale - matrix[0, 0] - matrix[1, 1] + matrix[2, 2])) / 2);

            xyz = new Vector3(x, y, z);

            if (matrix[2, 1] - matrix[1, 2] < 0)
            {
                X = -X;
            }
            if (matrix[0, 2] - matrix[2, 0] < 0)
            {
                Y = -Y;
            }
            if (matrix[1, 0] - matrix[0, 1] < 0)
            {
                Z = -Z;
            }
        }
Esempio n. 2
0
 // Apple deprecated initWithName:floatMatrix3: in macOS10.12/iOS10.0
 // and made available initWithName:matrixFloat3x3: so we invoke
 // the right one at runtime depending on which OS version we are running
 public SKUniform(string name, Matrix3 value)
 {
     if (CheckSystemVersion())
     {
         InitializeHandle(InitWithNameMatrixFloat3x3(name, value), "initWithName:matrixFloat3x3:");
     }
     else
     {
         InitializeHandle(InitWithNameFloatMatrix3(name, value), "initWithName:floatMatrix3:");
     }
 }