Ejemplo n.º 1
0
 public SCNMatrix4(CoreAnimation.CATransform3D transform)
 {
     Row0 = new SCNVector4((pfloat)transform.m11, (pfloat)transform.m12, (pfloat)transform.m13, (pfloat)transform.m14);
     Row1 = new SCNVector4((pfloat)transform.m21, (pfloat)transform.m22, (pfloat)transform.m23, (pfloat)transform.m24);
     Row2 = new SCNVector4((pfloat)transform.m31, (pfloat)transform.m32, (pfloat)transform.m33, (pfloat)transform.m34);
     Row3 = new SCNVector4((pfloat)transform.m41, (pfloat)transform.m42, (pfloat)transform.m43, (pfloat)transform.m44);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructs a new instance.
 /// </summary>
 /// <param name="row0">Top row of the matrix</param>
 /// <param name="row1">Second row of the matrix</param>
 /// <param name="row2">Third row of the matrix</param>
 /// <param name="row3">Bottom row of the matrix</param>
 public SCNMatrix4(SCNVector4 row0, SCNVector4 row1, SCNVector4 row2, SCNVector4 row3)
 {
     Row0 = row0;
     Row1 = row1;
     Row2 = row2;
     Row3 = row3;
 }
Ejemplo n.º 3
0
        public SCNVector4 ToAxisAngle()
        {
            SCNQuaternion q = this;

            if (q.W > 1.0f)
            {
                q.Normalize();
            }

            SCNVector4 result = new SCNVector4();

            result.W = 2.0f * (pfloat)System.Math.Acos(q.W); // angle
            pfloat den = (pfloat)System.Math.Sqrt(1.0 - q.W * q.W);

            if (den > 0.0001f)
            {
                result.Xyz = q.Xyz / den;
            }
            else
            {
                // This occurs when the angle is zero.
                // Not a problem: just set an arbitrary normalized axis.
                result.Xyz = SCNVector3.UnitX;
            }

            return(result);
        }
Ejemplo n.º 4
0
        public void ToAxisAngle(out SCNVector3 axis, out pfloat angle)
        {
            SCNVector4 result = ToAxisAngle();

            axis  = result.Xyz;
            angle = result.W;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructs a new instance.
 /// </summary>
 /// <param name="m00">First item of the first row of the matrix.</param>
 /// <param name="m01">Second item of the first row of the matrix.</param>
 /// <param name="m02">Third item of the first row of the matrix.</param>
 /// <param name="m03">Fourth item of the first row of the matrix.</param>
 /// <param name="m10">First item of the second row of the matrix.</param>
 /// <param name="m11">Second item of the second row of the matrix.</param>
 /// <param name="m12">Third item of the second row of the matrix.</param>
 /// <param name="m13">Fourth item of the second row of the matrix.</param>
 /// <param name="m20">First item of the third row of the matrix.</param>
 /// <param name="m21">Second item of the third row of the matrix.</param>
 /// <param name="m22">Third item of the third row of the matrix.</param>
 /// <param name="m23">First item of the third row of the matrix.</param>
 /// <param name="m30">Fourth item of the fourth row of the matrix.</param>
 /// <param name="m31">Second item of the fourth row of the matrix.</param>
 /// <param name="m32">Third item of the fourth row of the matrix.</param>
 /// <param name="m33">Fourth item of the fourth row of the matrix.</param>
 public SCNMatrix4(
     pfloat m00, pfloat m01, pfloat m02, pfloat m03,
     pfloat m10, pfloat m11, pfloat m12, pfloat m13,
     pfloat m20, pfloat m21, pfloat m22, pfloat m23,
     pfloat m30, pfloat m31, pfloat m32, pfloat m33)
 {
     Row0 = new SCNVector4(m00, m01, m02, m03);
     Row1 = new SCNVector4(m10, m11, m12, m13);
     Row2 = new SCNVector4(m20, m21, m22, m23);
     Row3 = new SCNVector4(m30, m31, m32, m33);
 }
Ejemplo n.º 6
0
        public static SCNVector4 Transform(SCNVector3 vec, SCNMatrix4 mat)
        {
            SCNVector4 v4 = new SCNVector4(vec.X, vec.Y, vec.Z, 1.0f);
            SCNVector4 result;

            result.X = SCNVector4.Dot(v4, mat.Column0);
            result.Y = SCNVector4.Dot(v4, mat.Column1);
            result.Z = SCNVector4.Dot(v4, mat.Column2);
            result.W = SCNVector4.Dot(v4, mat.Column3);
            return(result);
        }
Ejemplo n.º 7
0
        public static SCNVector3 TransformPerspective(SCNVector3 vec, SCNMatrix4 mat)
        {
            SCNVector4 h = Transform(vec, mat);

            return(new SCNVector3(h.X / h.W, h.Y / h.W, h.Z / h.W));
        }
Ejemplo n.º 8
0
        public static void Transform(ref SCNVector3 vec, ref SCNMatrix4 mat, out SCNVector4 result)
        {
            SCNVector4 v4 = new SCNVector4(vec.X, vec.Y, vec.Z, 1.0f);

            SCNVector4.Transform(ref v4, ref mat, out result);
        }
Ejemplo n.º 9
0
 public SCNVector3(SCNVector4 v)
 {
     X = v.X;
     Y = v.Y;
     Z = v.Z;
 }