@@ -31,7 +31,7 @@ public static float DistanceTo(this Vector3 source, Vector3 destination)
3131 }
3232
3333 /// <summary>
34- /// Return the <see cref="Vector3"/> with its Y-component to 0.
34+ /// Return the <see cref="Vector3"/> with its Y-component at 0.
3535 /// </summary>
3636 /// <returns>A modified <see cref="Vector3"/> with y component set to 0.</returns>
3737 public static Vector3 Flat ( this Vector3 source )
@@ -40,6 +40,63 @@ public static Vector3 Flat(this Vector3 source)
4040 new Vector3 ( source . x , 0 , source . z ) ;
4141 }
4242
43+ /// <summary>
44+ /// Returns the <see cref="Vector3"/> with a set <paramref name="x"/> component, and Y- and Z-components
45+ /// scaled to match while retaining the X,Y,Z proportions of the source <see cref="Vector3"/>.
46+ /// </summary>
47+ /// <param name="x">
48+ /// A X-component value for the scaled <see cref="Vector3"/>.
49+ /// </param>
50+ /// <returns>
51+ /// A <see cref="Vector3"/>.
52+ /// </returns>
53+ public static Vector3 ScaledToX ( this Vector3 source , float x )
54+ {
55+ var factor = x / source . x ;
56+ var y = source . y * factor ;
57+ var z = source . z * factor ;
58+ return
59+ new ( x , y , z ) ;
60+ }
61+
62+ /// <summary>
63+ /// Returns the <see cref="Vector3"/> with a set <paramref name="y"/> component, and X- and Z-components
64+ /// scaled to match while retaining the X,Y,Z proportions of the source <see cref="Vector3"/>.
65+ /// </summary>
66+ /// <param name="y">
67+ /// A Y-component value for the scaled <see cref="Vector3"/>.
68+ /// </param>
69+ /// <returns>
70+ /// A <see cref="Vector3"/>.
71+ /// </returns>
72+ public static Vector3 ScaledToY ( this Vector3 source , float y )
73+ {
74+ var factor = y / source . y ;
75+ var x = source . x * factor ;
76+ var z = source . z * factor ;
77+ return
78+ new ( x , y , z ) ;
79+ }
80+
81+ /// <summary>
82+ /// Returns the <see cref="Vector3"/> with a set <paramref name="z"/> component, and X- and Y-components
83+ /// scaled to match while retaining the X,Y,Z proportions of the source <see cref="Vector3"/>.
84+ /// </summary>
85+ /// <param name="z">
86+ /// A Z-component value for the scaled <see cref="Vector3"/>.
87+ /// </param>
88+ /// <returns>
89+ /// A <see cref="Vector3"/>.
90+ /// </returns>
91+ public static Vector3 ScaledToZ ( this Vector3 source , float z )
92+ {
93+ var factor = z / source . z ;
94+ var x = source . x * factor ;
95+ var y = source . y * factor ;
96+ return
97+ new ( x , y , z ) ;
98+ }
99+
43100 /// <summary>
44101 /// Converts a <see cref="Vector3"/>[] into a <see cref="Vector2"/>[].
45102 /// </summary>
0 commit comments