/// <summary>
        /// Scales the <see cref="Vector3"/> by the scaling with the option to ignore some dimensions flags.
        /// </summary>
        /// <param name="scaler">The scaling service.</param>
        /// <param name="vector">The vector to scale.</param>
        /// <param name="ignoreFlags">Which dimensions to ignore.</param>
        /// <returns>A new scaled vector.</returns>
        public static Vector3 Scale(this IUnitScalerStrategy scaler, Vector3 vector, UnitScaleFlags ignoreFlags)
        {
            float x = ignoreFlags.QuickFlagsCheck(UnitScaleFlags.X) ? vector.x : scaler.ScaleX(vector.x);
            float y = ignoreFlags.QuickFlagsCheck(UnitScaleFlags.Y) ? vector.y : scaler.ScaleY(vector.y);;
            float z = ignoreFlags.QuickFlagsCheck(UnitScaleFlags.Z) ? vector.z : scaler.ScaleZ(vector.z);;

            return(new Vector3(x, y, z));
        }
Example #2
0
        /// <summary>
        /// Scales the <see cref="Vector3"/> by the scaling with the option to ignore some dimensions flags.
        /// </summary>
        /// <param name="scaler">The scaling service.</param>
        /// <param name="vector">The vector to scale.</param>
        /// <param name="ignoreFlags">Which dimensions to ignore.</param>
        /// <returns>A new scaled vector.</returns>
        public static Vector3 <float> Scale(this IUnitScalerStrategy scaler, Vector3 <float> vector, UnitScaleFlags ignoreFlags)
        {
            float x = ignoreFlags.QuickFlagsCheck(UnitScaleFlags.X) ? vector.X : scaler.ScaleX(vector.X);
            float y = ignoreFlags.QuickFlagsCheck(UnitScaleFlags.Y) ? vector.Y : scaler.ScaleY(vector.Y);;
            float z = ignoreFlags.QuickFlagsCheck(UnitScaleFlags.Z) ? vector.Z : scaler.ScaleZ(vector.Z);;

            return(new Vector3 <float>(x, y, z));
        }
 /// <summary>
 /// Scales the <see cref="Vector3"/> by the scaling.
 /// Will use the vector2's Y component as the Vector3's Z component.
 /// Will use the Y component of the original vector.
 /// </summary>
 /// <param name="scaler">The scaling service.</param>
 /// <param name="vector">The vector to scale.</param>
 /// <returns>A new scaled vector.</returns>
 public static Vector3 ScaleYtoZ(this IUnitScalerStrategy scaler, Vector3 vector)
 {
     return(new Vector3(scaler.ScaleX(vector.x), vector.y, scaler.ScaleZ(vector.z)));
 }
 /// <summary>
 /// Fully scales the <see cref="Vector2"/> by the scaling.
 /// </summary>
 /// <param name="scaler">The scaling service.</param>
 /// <param name="vector">The vector to scale.</param>
 /// <returns>A new scaled vector.</returns>
 public static Vector2 Scale(this IUnitScalerStrategy scaler, Vector2 <float> vector)
 {
     return(new Vector2(scaler.ScaleX(vector.X), scaler.ScaleY(vector.Y)));
 }
 /// <summary>
 /// Fully scales the <see cref="Vector2"/> by the scaling.
 /// </summary>
 /// <param name="scaler">The scaling service.</param>
 /// <param name="vector">The vector to scale.</param>
 /// <returns>A new scaled vector.</returns>
 public static Vector2 ScaleYasZ(this IUnitScalerStrategy scaler, Vector2 vector)
 {
     return(new Vector3(scaler.ScaleX(vector.x), scaler.ScaleZ(vector.y)));
 }
 /// <summary>
 /// Unscales the Y rotation based on the unit scale.
 /// </summary>
 /// <param name="scaler">The scaler.</param>
 /// <param name="rotation">The rotation to scale.</param>
 /// <returns></returns>
 public static float UnScaleYRotation(this IUnitScalerStrategy scaler, float rotation)
 {
     //TODO: IS this right?
     //This is odd but if we have both Z and X flipped then the Y will be the same.
     return((Math.Sign(scaler.ScaleZ(1)) + Math.Sign(scaler.ScaleX(1))) <= 0.0f ? -rotation : rotation);
 }
Example #7
0
 /// <summary>
 /// Scales the <see cref="Vector3"/> by the scaling.
 /// Will use the vector2's Y component as the Vector3's Z component.
 /// Will use the Y component of the original vector.
 /// </summary>
 /// <param name="scaler">The scaling service.</param>
 /// <param name="vector">The vector to scale.</param>
 /// <returns>A new scaled vector.</returns>
 public static Vector3 <float> ScaleYtoZ(this IUnitScalerStrategy scaler, Vector3 <float> vector)
 {
     return(new Vector3 <float>(scaler.ScaleX(vector.X), vector.Y, scaler.ScaleZ(vector.Z)));
 }