@@ -16,38 +16,6 @@ namespace Silk.NET.Maths
1616 /// <summary>A structure representing a 2D floating-point vector.</summary>
1717 internal partial struct Vector2F < T >
1818 {
19- /// <summary>Gets the squared length of the vector (dot product with itself).</summary>
20- public T LengthSquared => ( X * X ) + ( Y * Y ) ;
21-
22- /// <summary>Gets the length of the vector.</summary>
23- public T Length => T . Sqrt ( LengthSquared ) ;
24-
25- /// <summary> Computes the dot product of this vector with another vector. </summary>
26- public T Dot ( Vector2F < T > other ) => ( X * other . X ) + ( Y * other . Y ) ;
27-
28- /// <summary> Computes the dot product of two vectors. </summary>
29- public static T Dot ( Vector2F < T > left , Vector2F < T > right ) => ( left . X * right . X ) + ( left . Y * right . Y ) ;
30-
31- /// <summary> Computes the cross product of this vector with another vector. </summary>
32- public T Cross ( Vector2F < T > other ) => ( X * other . Y ) - ( Y * other . X ) ;
33-
34- /// <summary> Computes the cross product of two vectors. </summary>
35- public static T Cross ( Vector2F < T > left , Vector2F < T > right ) => ( left . X * right . Y ) - ( left . Y * right . X ) ;
36-
37- /// <summary>Normalizes this vector.</summary>
38- public Vector2F < T > Normalize ( )
39- {
40- T length = Length ;
41- return length != T . Zero ? this / length : Zero ;
42- }
43-
44- /// <summary>Normalizes a vector.</summary>
45- public static Vector2F < T > Normalize ( Vector2F < T > vector )
46- {
47- T length = vector . Length ;
48- return length != T . Zero ? vector / length : Zero ;
49- }
50-
5119 /// <summary>Returns a vector with the component-wise maximum of this and another vector.</summary>
5220 public Vector2F < T > Max ( Vector2F < T > other ) =>
5321 new ( T . Max ( X , other . X ) , T . Max ( Y , other . Y ) ) ;
@@ -122,20 +90,6 @@ public static Vector2F<T> LerpClamped(Vector2F<T> a, Vector2F<T> b, Vector2F<T>
12290 a . Y + ( b . Y - a . Y ) * T . Clamp ( t . Y , T . Zero , T . One )
12391 ) ;
12492
125- /// <summary>Reflects a vector over a normal vector.</summary>
126- public Vector2F < T > Reflect ( Vector2F < T > normal )
127- {
128- T dot = Dot ( normal ) ;
129- return this - ( normal * ( dot + dot ) ) ;
130- }
131-
132- /// <summary>Reflects a vector over a normal vector.</summary>
133- public static Vector2F < T > Reflect ( Vector2F < T > vector , Vector2F < T > normal )
134- {
135- T dot = Dot ( vector , normal ) ;
136- return vector - ( normal * ( dot + dot ) ) ;
137- }
138-
13993 /// <summary>Returns a vector where each component is the sign of the original vector's component.</summary>
14094 public Vector2F < T > Sign ( ) => new ( T . CreateChecked ( T . Sign ( X ) ) , T . CreateChecked ( T . Sign ( Y ) ) ) ;
14195
@@ -358,4 +312,11 @@ public static Vector2F<T> ScaleB(Vector2F<T> x, Vector2I<int> n) =>
358312 public static Vector2F < T > ScaleB ( Vector2F < T > x , int n ) =>
359313 new ( T . ScaleB ( x . X , n ) , T . ScaleB ( x . Y , n ) ) ;
360314 }
315+
316+ static partial class Vector2F
317+ {
318+ /// <summary> Computes the cross product of two vectors.</summary>
319+ public static T Cross < T > ( this Vector2F < T > left , Vector2F < T > right )
320+ where T : IFloatingPointIeee754 < T > => ( left . X * right . Y ) - ( left . Y * right . X ) ;
321+ }
361322}
0 commit comments