Class Vector2dExtensions
- Namespace
- FixedMathSharp
- Assembly
- FixedMathSharp.dll
Provides extension methods for the Vector2d type to support additional vector operations, comparisons, and conversions.
public static class Vector2dExtensions
- Inheritance
-
Vector2dExtensions
- Inherited Members
Methods
Abs(Vector2d)
Returns a new Vector2d where each component is the absolute value of the corresponding input component.
public static Vector2d Abs(this Vector2d value)
Parameters
valueVector2dThe input vector.
Returns
- Vector2d
A vector with absolute values for each component.
CheckDistance(Vector2d, Vector2d, Fixed64)
Checks if the distance between two vectors is less than or equal to a specified factor.
public static bool CheckDistance(this Vector2d me, Vector2d other, Fixed64 factor)
Parameters
meVector2dThe current vector.
otherVector2dThe vector to compare distance to.
factorFixed64The maximum allowable distance.
Returns
- bool
True if the distance between the vectors is less than or equal to the factor, false otherwise.
Clamp(Vector2d, Vector2d, Vector2d)
Clamps each component of the given vector within the specified min and max bounds.
public static Vector2d Clamp(this Vector2d value, Vector2d min, Vector2d max)
Parameters
Returns
ClampOne(Vector2d)
Clamps each component of the given vector within the specified min and max bounds.
public static Vector2d ClampOne(this Vector2d value)
Parameters
valueVector2d
Returns
FuzzyEqual(Vector2d, Vector2d, Fixed64?)
Compares two vectors for approximate equality, allowing a fractional difference (percentage). Handles zero components by only using the allowed percentage difference.
public static bool FuzzyEqual(this Vector2d me, Vector2d other, Fixed64? percentage = null)
Parameters
meVector2dThe current vector.
otherVector2dThe vector to compare against.
percentageFixed64?The allowed fractional difference (percentage) for each component.
Returns
- bool
True if the components are within the allowed percentage difference, false otherwise.
FuzzyEqualAbsolute(Vector2d, Vector2d, Fixed64)
Compares two vectors for approximate equality, allowing a fixed absolute difference.
public static bool FuzzyEqualAbsolute(this Vector2d me, Vector2d other, Fixed64 allowedDifference)
Parameters
meVector2dThe current vector.
otherVector2dThe vector to compare against.
allowedDifferenceFixed64The allowed absolute difference between each component.
Returns
- bool
True if the components are within the allowed difference, false otherwise.
Rotate(Vector2d, Fixed64)
Rotates this vector by the specified angle (in radians).
public static Vector2d Rotate(this Vector2d vec, Fixed64 angleInRadians)
Parameters
Returns
- Vector2d
The rotated vector.
Sign(Vector2d)
Returns a new Vector2d where each component is the sign of the corresponding input component.
public static Vector2d Sign(this Vector2d value)
Parameters
valueVector2dThe input vector.
Returns
- Vector2d
A vector where each component is -1, 0, or 1 based on the sign of the input.
ToDegrees(Vector2d)
Converts each component of the vector from radians to degrees.
public static Vector2d ToDegrees(this Vector2d radians)
Parameters
radiansVector2dThe vector with components in radians.
Returns
- Vector2d
A new vector with components converted to degrees.
ToRadians(Vector2d)
Converts each component of the vector from degrees to radians.
public static Vector2d ToRadians(this Vector2d degrees)
Parameters
degreesVector2dThe vector with components in degrees.
Returns
- Vector2d
A new vector with components converted to radians.
TryRotate(Vector2d, Fixed64, out Vector2d)
Attempts to rotate a vector by the specified angle with one final round-half-to-even conversion per component.
public static bool TryRotate(this Vector2d vector, Fixed64 angleInRadians, out Vector2d result)