@@ -24,8 +24,14 @@ public partial struct Vector2d : IEquatable<Vector2d>, IComparable<Vector2d>, IE
24
24
{
25
25
#region Fields and Constants
26
26
27
+ /// <summary>
28
+ /// The X component of the vector.
29
+ /// </summary>
27
30
public Fixed64 x ;
28
-
31
+
32
+ /// <summary>
33
+ /// The Y component of the vector.
34
+ /// </summary>
29
35
public Fixed64 y ;
30
36
31
37
/// <summary>
@@ -128,12 +134,16 @@ public Vector2d LeftHandNormal
128
134
get => new Vector2d ( y , - x ) ;
129
135
}
130
136
137
+ /// <inheritdoc cref="GetNormalized(Vector2d)"/>
131
138
public Vector2d Normal
132
139
{
133
140
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
134
141
get => GetNormalized ( this ) ;
135
142
}
136
143
144
+ /// <summary>
145
+ /// Returns the actual length of this vector (RO).
146
+ /// </summary>
137
147
public Fixed64 Magnitude
138
148
{
139
149
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
@@ -234,6 +244,7 @@ public Vector2d AddInPlace(Fixed64 xAmount, Fixed64 yAmount)
234
244
return this ;
235
245
}
236
246
247
+ /// <inheritdoc cref="AddInPlace(Fixed64, Fixed64)"/>
237
248
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
238
249
public Vector2d AddInPlace ( Vector2d other )
239
250
{
@@ -515,12 +526,19 @@ public Fixed64 Dot(Vector2d other)
515
526
return Dot ( other . x , other . y ) ;
516
527
}
517
528
529
+ /// <summary>
530
+ /// Computes the cross product magnitude of this vector with another vector.
531
+ /// </summary>
532
+ /// <param name="otherX">The X component of the other vector.</param>
533
+ /// <param name="otherY">The Y component of the other vector.</param>
534
+ /// <returns>The cross product magnitude.</returns>
518
535
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
519
536
public Fixed64 CrossProduct ( Fixed64 otherX , Fixed64 otherY )
520
537
{
521
538
return x * otherY - y * otherX ;
522
539
}
523
540
541
+ /// <inheritdoc cref="CrossProduct(Fixed64, Fixed64)"/>
524
542
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
525
543
public Fixed64 CrossProduct ( Vector2d other )
526
544
{
@@ -607,12 +625,28 @@ public static Fixed64 GetMagnitude(Vector2d vector)
607
625
return temp1 . Abs ( ) > Fixed64 . Zero ? FixedMath . Sqrt ( temp1 ) : Fixed64 . Zero ;
608
626
}
609
627
628
+ /// <summary>
629
+ /// Returns a new <see cref="Vector2d"/> where each component is the absolute value of the corresponding input component.
630
+ /// </summary>
631
+ /// <param name="value">The input vector.</param>
632
+ /// <returns>A vector with absolute values for each component.</returns>
610
633
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
611
634
public static Vector2d Abs ( Vector2d value )
612
635
{
613
636
return new Vector2d ( value . x . Abs ( ) , value . y . Abs ( ) ) ;
614
637
}
615
638
639
+ /// <summary>
640
+ /// Returns a new <see cref="Vector2d"/> where each component is the sign of the corresponding input component.
641
+ /// </summary>
642
+ /// <param name="value">The input vector.</param>
643
+ /// <returns>A vector where each component is -1, 0, or 1 based on the sign of the input.</returns>
644
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
645
+ public static Vector2d Sign ( Vector2d value )
646
+ {
647
+ return new Vector2d ( value . x . Sign ( ) , value . y . Sign ( ) ) ;
648
+ }
649
+
616
650
/// <summary>
617
651
/// Creates a vector from a given angle in radians.
618
652
/// </summary>
@@ -633,6 +667,10 @@ public static Fixed64 Distance(Vector2d start, Vector2d end)
633
667
return start . Distance ( end ) ;
634
668
}
635
669
670
+ /// <summary>
671
+ /// Calculates the squared distance between two vectors, avoiding the need for a square root operation.
672
+ /// </summary>
673
+ /// <returns>The squared distance between the two vectors.</returns>
636
674
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
637
675
public static Fixed64 SqrDistance ( Vector2d start , Vector2d end )
638
676
{
@@ -712,6 +750,15 @@ public override string ToString()
712
750
return $ "({ Math . Round ( ( double ) x , 2 ) } , { Math . Round ( ( double ) y , 2 ) } )";
713
751
}
714
752
753
+ /// <summary>
754
+ /// Converts this <see cref="Vector2d"/> to a <see cref="Vector3d"/>,
755
+ /// mapping the Y component of this vector to the Z axis in the resulting vector.
756
+ /// </summary>
757
+ /// <param name="z">The value to assign to the Y axis of the resulting <see cref="Vector3d"/>.</param>
758
+ /// <returns>
759
+ /// A new <see cref="Vector3d"/> where (X, Y) from this <see cref="Vector2d"/>
760
+ /// become (X, Z) in the resulting vector, with the provided Z parameter assigned to Y.
761
+ /// </returns>
715
762
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
716
763
public Vector3d ToVector3d ( Fixed64 z )
717
764
{
0 commit comments