Beispiel #1
0
        public static float[] RotateAroundCenter(float[] pVertices, float pRotation, float pRotationCenterX, float pRotationCenterY)
        {
            if (pRotation != 0)
            {
                float rotationRad      = MathUtils.DegToRad(pRotation);
                float sinRotationRad   = FloatMath.Sin(rotationRad);
                float cosRotationInRad = FloatMath.Cos(rotationRad);

                for (int i = pVertices.Length - 2; i >= 0; i -= 2)
                {
                    float pX = pVertices[i];
                    float pY = pVertices[i + 1];
                    pVertices[i]     = pRotationCenterX + (cosRotationInRad * (pX - pRotationCenterX) - sinRotationRad * (pY - pRotationCenterY));
                    pVertices[i + 1] = pRotationCenterY + (sinRotationRad * (pX - pRotationCenterX) + cosRotationInRad * (pY - pRotationCenterY));
                }
            }
            return(pVertices);
        }
Beispiel #2
0
        /**
         * Not tested for now!
         */
        //@Deprecated
        /// <summary>
        /// Decprecated and untested
        /// </summary>
        /// <param name="IShape"></param>
        public void accelerateRespectingRotation(/* final */ IShape pShape, /* final */ float pAccelerationX, /* final */ float pAccelerationY)
        {
            /* final */
            float rotation = pShape.GetRotation();
            /* final */
            float rotationRad = MathUtils.DegToRad(rotation);

            /* final */
            float sin = FloatMath.Sin(rotationRad);
            /* final */
            float cos = FloatMath.Cos(rotationRad);

            /* final */
            float accelerationX = sin * -pAccelerationY + cos * pAccelerationX;
            /* final */
            float accelerationY = cos * pAccelerationY + sin * pAccelerationX;

            pShape.SetAcceleration(accelerationX, accelerationY);
        }
Beispiel #3
0
        // ===========================================================
        // Constants
        // ===========================================================

        // ===========================================================
        // Fields
        // ===========================================================

        // ===========================================================
        // Constructors
        // ===========================================================

        // ===========================================================
        // Getter & Setter
        // ===========================================================

        // ===========================================================
        // Methods for/from SuperClass/Interfaces
        // ===========================================================

        /**
         * Not tested for now!
         */
        // @Deprecated
        /// <summary>
        /// Deprecated and untested
        /// </summary>
        /// <param name="IShape"></param>
        public void setVelocityRespectingRotation(/* final */ IShape pShape, /* final */ float pVelocityX, /* final */ float pVelocityY)
        {
            /* final */
            float rotation = pShape.GetRotation();
            /* final */
            float rotationRad = MathUtils.DegToRad(rotation);

            /* final */
            float sin = FloatMath.Sin(rotationRad);
            /* final */
            float cos = FloatMath.Cos(rotationRad);

            /* final */
            float velocityX = sin * -pVelocityY + cos * pVelocityX;
            /* final */
            float velocityY = cos * pVelocityY + sin * pVelocityX;

            pShape.SetVelocity(velocityX, velocityY);
        }