Example #1
0
        public static Quaternion ReverseRotation(this AxisOrder target, CustomRotation relative, Quaternion?current = null)  //WORKS!
        {
            Quaternion newRot;

            if (current != null)
            {
                newRot = (Quaternion)current;
            }
            else
            {
                newRot = relative.rotation;
            }

            if (target.variety == SpaceVariety.OneSided)
            {
                for (int j = target.axes.Count; j > 0; j--)
                {
                    AxisApplied i = target.axes[j - 1];

                    newRot = relative.Rotate(newRot, (Vectors.axisDirections[i.axis] * -i.units), target.space);
                }
            }
            else if (target.variety == SpaceVariety.Mixed)
            {
                for (int j = target.axes.Count; j > 0; j--)
                {
                    AxisApplied i = target.axes[j - 1];

                    newRot = relative.Rotate(newRot, (Vectors.axisDirections[i.axis] * -i.units), i.space);
                }
            }

            return(newRot);
        }
Example #2
0
        public static Vector3 ReversePosition(this AxisOrder target, CustomPosition relative, Vector3?current = null, float scale = 1f)  //takes and return GLOBAL
        {
            Vector3 newPos;

            if (current != null)
            {
                newPos = (Vector3)current;
            }
            else
            {
                newPos = relative.position;
            }

            if (target.variety == SpaceVariety.OneSided)
            {
                for (int j = target.axes.Count; j > 0; j--)
                {
                    AxisApplied i = target.axes[j - 1];

                    newPos = relative.Translate(newPos, -(Vectors.axisDirections[i.axis] * i.units) * scale, target.space);
                }
            }
            else if (target.variety == SpaceVariety.Mixed)
            {
                for (int j = target.axes.Count; j > 0; j--)
                {
                    AxisApplied i = target.axes[j - 1];

                    newPos = relative.Translate(newPos, -(Vectors.axisDirections[i.axis] * i.units) * scale, i.space);
                }
            }
            return(newPos);
        } //WORKS!