示例#1
0
 public OBB(LVector2 pos, LVector2 size, LVector2 up)
 {
     this.pos  = pos;
     this.size = size;
     radius    = size.magnitude;
     this.up   = up;
     this.deg  = LMath.Atan2(-up.x, up.y);
 }
示例#2
0
 public static LVector3 ToEulerAngles(LQuaternion rotation)
 {
     rotation.Normalize();
     return(new LVector3(
                LMath.Atan2(2 * (rotation.w * rotation.z + rotation.x * rotation.y), 1 - 2 * (rotation.z * rotation.z + rotation.x * rotation.x)),
                LMath.Asin(2 * (rotation.w * rotation.x - rotation.y * rotation.z)),
                LMath.Atan2(2 * (rotation.w * rotation.y + rotation.z * rotation.x), 1 - 2 * (rotation.x * rotation.x + rotation.y * rotation.y))
                ));
 }
示例#3
0
        private LVector3 MatrixToEuler(LMatrix33 m)
        {
            LVector3 v = new LVector3();

            if (m[1, 2] < 1)
            {
                if (m[1, 2] > -1)
                {
                    v.x = LMath.Asin(-m[1, 2]);
                    v.y = LMath.Atan2(m[0, 2], m[2, 2]);
                    v.z = LMath.Atan2(m[1, 0], m[1, 1]);
                }
                else
                {
                    v.x = LMath.PI * LFloat.half;
                    v.y = LMath.Atan2(m[0, 1], m[0, 0]);
                    v.z = (LFloat)0;
                }
            }
            else
            {
                v.x = -LMath.PI * LFloat.half;
                v.y = LMath.Atan2(-m[0, 1], m[0, 0]);
                v.z = (LFloat)0;
            }

            for (int i = 0; i < 3; i++)
            {
                if (v[i] < 0)
                {
                    v[i] += LMath.PI2;
                }
                else if (v[i] > LMath.PI2)
                {
                    v[i] -= LMath.PI2;
                }
            }

            return(v);
        }
示例#4
0
 public void SetUp(LVector2 up)
 {
     this.up  = up;
     this.deg = LMath.Atan2(-up.x, up.y);
 }