示例#1
0
        //---------------------------------------------------------------------------
        // setupParentToLocal
        //
        // Setup the matrix to perform a parent -> local transformation, given
        // the position and orientation of the local reference frame within the
        // parent reference frame.
        //
        // A very common use of this will be to construct a world -> object matrix.
        // To perform this transformation, we would normally FIRST transform
        // from world to inertial space, and then rotate from inertial space into
        // object space.  However, out 4x3 matrix always translates last.  So
        // we think about creating two matrices T and R, and then concatonating
        // M = TR.
        //
        // We allow the orientation to be specified using either euler angles,
        // or a RotationMatrix
        public void setupParentToLocal(Vector3 pos, EulerAngles orient)
        {
            // Create a rotation matrix.

            RotationMatrix orientMatrix = new RotationMatrix();
            orientMatrix.setup(orient);

            // Setup the 4x3 matrix.

            setupParentToLocal(pos, orientMatrix);
        }
示例#2
0
        //---------------------------------------------------------------------------
        // RotationMatrix::setup
        //
        // Setup the matrix with the specified orientation
        //
        // See 10.6.1
        public void setup(EulerAngles orientation)
        {
            // Fetch sine and cosine of angles

            float	sh,ch, sp,cp, sb,cb;
            MathUtil.sinCos(out sh, out ch, orientation.Heading);
            MathUtil.sinCos(out sp, out cp, orientation.Pitch);
            MathUtil.sinCos(out sb, out cb, orientation.Bank);

            // Fill in the matrix elements

            m11 = ch * cb + sh * sp * sb;
            m12 = -ch * sb + sh * sp * cb;
            m13 = sh * cp;

            m21 = sb * cp;
            m22 = cb * cp;
            m23 = -sp;

            m31 = -sh * cb + ch * sp * sb;
            m32 = sb * sh + ch * sp * cb;
            m33 = ch * cp;
        }
示例#3
0
        //---------------------------------------------------------------------------
        // setupLocalToParent
        //
        // Setup the matrix to perform a local -> parent transformation, given
        // the position and orientation of the local reference frame within the
        // parent reference frame.
        //
        // A very common use of this will be to construct a object -> world matrix.
        // As an example, the transformation in this case is straightforward.  We
        // first rotate from object space into inertial space, then we translate
        // into world space.
        //
        // We allow the orientation to be specified using either euler angles,
        // or a RotationMatrix
        public void setupLocalToParent(Vector3 pos, EulerAngles orient)
        {
            // Create a rotation matrix.

            RotationMatrix orientMatrix = new RotationMatrix();
            orientMatrix.setup(orient);

            // Setup the 4x3 matrix.  Note: if we were really concerned with
            // speed, we could create the matrix directly into these variables,
            // without using the temporary RotationMatrix object.  This would
            // save us a function call and a few copy operations.

            setupLocalToParent(pos, orientMatrix);
        }
示例#4
0
        //---------------------------------------------------------------------------
        // EulerAngles::setToRotateObjectToInertial
        //
        // Setup the quaternion to perform an object->inertial rotation, given the
        // orientation in Euler angle format
        //
        // See 10.6.5 for more information.
        public void setToRotateObjectToInertial(EulerAngles orientation)
        {
            // Compute sine and cosine of the half angles

            float	sp, sb, sh;
            float	cp, cb, ch;
            MathUtil.sinCos(out sp, out cp, orientation.Pitch * 0.5f);
            MathUtil.sinCos(out sb, out cb, orientation.Bank * 0.5f);
            MathUtil.sinCos(out sh, out ch, orientation.Heading * 0.5f);

            // Compute values

            w =  ch*cp*cb + sh*sp*sb;
            x =  ch*sp*cb + sh*cp*sb;
            y = -ch*sp*sb + sh*cp*cb;
            z = -sh*sp*cb + ch*cp*sb;
        }