Table of Contents

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

value Vector2d

The 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

me Vector2d

The current vector.

other Vector2d

The vector to compare distance to.

factor Fixed64

The 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

value Vector2d
min Vector2d
max Vector2d

Returns

Vector2d

ClampOne(Vector2d)

Clamps each component of the given vector within the specified min and max bounds.

public static Vector2d ClampOne(this Vector2d value)

Parameters

value Vector2d

Returns

Vector2d

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

me Vector2d

The current vector.

other Vector2d

The vector to compare against.

percentage Fixed64?

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

me Vector2d

The current vector.

other Vector2d

The vector to compare against.

allowedDifference Fixed64

The 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

vec Vector2d

The vector to rotate.

angleInRadians Fixed64

The angle in radians.

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

value Vector2d

The 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

radians Vector2d

The 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

degrees Vector2d

The 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)

Parameters

vector Vector2d
angleInRadians Fixed64
result Vector2d

Returns

bool

true when both final components are representable; otherwise, false and result is default.