Exemple #1
0
        private void ApplyRotationToPoints()
        {
            if (m_Rotation != 0)
            {
                var rads = m_Rotation * Mathf.Deg2Rad;
                var cos  = Mathf.Cos(rads);
                var sin  = Mathf.Sin(rads);

                var rotate = MatrixUtils.Rotate2d(cos, -sin, sin, cos);

                m_Points = m_Points.Select(p => rotate.MultiplyPoint(p)).Select(v3 => (Vector2)v3).ToArray();
            }
        }
        private void ApplyRotationToPoints()
        {
            if (m_Rotation != 0)
            {
                var rads = m_Rotation * Mathf.Deg2Rad;
                var cos  = Mathf.Cos(rads);
                var sin  = Mathf.Sin(rads);

                var transIn  = Matrix4x4.Translate(-m_Position);
                var rotate   = MatrixUtils.Rotate2d(cos, -sin, sin, cos);
                var transOut = Matrix4x4.Translate(m_Position);

                var matrix = transOut * rotate * transIn;

                m_Points = m_Points.Select(p => (Vector2)matrix.MultiplyPoint(p)).ToArray();
            }
        }