Table of Contents

Class Vector3dExtensions

Namespace
FixedMathSharp
Assembly
FixedMathSharp.dll

Provides extension methods for the Vector3d type to support additional vector operations, comparisons, and conversions.

public static class Vector3dExtensions
Inheritance
Vector3dExtensions
Inherited Members

Methods

Abs(Vector3d)

Returns a new Vector3d where each component is the absolute value of the corresponding input component.

public static Vector3d Abs(this Vector3d value)

Parameters

value Vector3d

The input vector.

Returns

Vector3d

A vector with absolute values for each component.

Angle(Vector3d, Vector3d)

Computes the angle in degrees between two vectors.

public static Fixed64 Angle(this Vector3d from, Vector3d to)

Parameters

from Vector3d

The starting vector.

to Vector3d

The target vector.

Returns

Fixed64

The angle in degrees between the two vectors.

Remarks

This method calculates the angle by using the dot product between the vectors and normalizing the result. The angle is always the smaller angle between the two vectors on a plane.

CheckDistance(Vector3d, Vector3d, Fixed64)

Checks if the distance between two vectors is less than or equal to a specified factor.

public static bool CheckDistance(this Vector3d me, Vector3d other, Fixed64 factor)

Parameters

me Vector3d

The current vector.

other Vector3d

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(Vector3d, Vector3d, Vector3d)

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

public static Vector3d Clamp(this Vector3d value, Vector3d min, Vector3d max)

Parameters

value Vector3d

The vector to clamp.

min Vector3d

The minimum bounds.

max Vector3d

The maximum bounds.

Returns

Vector3d

A vector with each component clamped between min and max.

ClampMagnitude(Vector3d, Fixed64)

Clamps the given Vector3d within the specified magnitude.

public static Vector3d ClampMagnitude(this Vector3d value, Fixed64 maxMagnitude)

Parameters

value Vector3d
maxMagnitude Fixed64

Returns

Vector3d

ClampOne(Vector3d)

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

public static Vector3d ClampOne(this Vector3d value)

Parameters

value Vector3d

The vector to clamp.

Returns

Vector3d

A vector with each component clamped between min and max.

Cross(Vector3d, Vector3d)

Cross Product of two vectors.

public static Vector3d Cross(this Vector3d lhs, Vector3d rhs)

Parameters

lhs Vector3d
rhs Vector3d

Returns

Vector3d

CrossProduct(Vector3d, Vector3d)

Computes the cross product magnitude of this vector with another vector.

public static Fixed64 CrossProduct(this Vector3d lhs, Vector3d rhs)

Parameters

lhs Vector3d
rhs Vector3d

Returns

Fixed64

The cross product magnitude.

Distance(Vector3d, Vector3d)

Computes the distance between this vector and another vector.

public static Fixed64 Distance(this Vector3d start, Vector3d end)

Parameters

start Vector3d
end Vector3d

Returns

Fixed64

The distance between the two vectors.

DistanceSquared(Vector3d, Vector3d)

Calculates the squared distance between two vectors, avoiding the need for a square root operation.

public static Fixed64 DistanceSquared(this Vector3d start, Vector3d end)

Parameters

start Vector3d
end Vector3d

Returns

Fixed64

The squared distance between the two vectors.

Dot(Vector3d, Vector3d)

Dot Product of two vectors.

public static Fixed64 Dot(this Vector3d lhs, Vector3d rhs)

Parameters

lhs Vector3d
rhs Vector3d

Returns

Fixed64

FuzzyEqual(Vector3d, Vector3d, 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 Vector3d me, Vector3d other, Fixed64? percentage = null)

Parameters

me Vector3d

The current vector.

other Vector3d

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(Vector3d, Vector3d, Fixed64)

Compares two vectors for approximate equality, allowing a fixed absolute difference.

public static bool FuzzyEqualAbsolute(this Vector3d me, Vector3d other, Fixed64 allowedDifference)

Parameters

me Vector3d

The current vector.

other Vector3d

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.

InverseRotate(Vector3d, Vector3d, FixedQuaternion)

Applies the inverse of a specified quaternion rotation to the vector around a given position.

public static Vector3d InverseRotate(this Vector3d source, Vector3d position, FixedQuaternion rotation)

Parameters

source Vector3d

The vector to rotate.

position Vector3d

The position around which the vector is rotated.

rotation FixedQuaternion

The quaternion representing the inverse rotation.

Returns

Vector3d

The rotated vector.

Lerp(Vector3d, Vector3d, Fixed64)

Linearly interpolates between two points.

public static Vector3d Lerp(this Vector3d start, Vector3d end, Fixed64 amount)

Parameters

start Vector3d
end Vector3d
amount Fixed64

Returns

Vector3d

Interpolated value, equals to a + (b - a) * t.

Project(Vector3d, Vector3d)

Projects a vector onto another vector.

public static Vector3d Project(this Vector3d vector, Vector3d onNormal)

Parameters

vector Vector3d
onNormal Vector3d

Returns

Vector3d

ProjectOnPlane(Vector3d, FixedPlane)

Projects a point onto a plane defined by a normal and a distance from the origin.

public static Vector3d ProjectOnPlane(this Vector3d point, FixedPlane plane)

Parameters

point Vector3d

The point to project.

plane FixedPlane

The plane onto which the point is projected.

Returns

Vector3d

The projected point.

ProjectOnPlane(Vector3d, Vector3d)

Projects a vector onto a plane defined by a normal orthogonal to the plane.

public static Vector3d ProjectOnPlane(this Vector3d vector, Vector3d planeNormal)

Parameters

vector Vector3d
planeNormal Vector3d

Returns

Vector3d

Reflect(Vector3d, Vector3d)

Reflects a vector off the plane defined by a normal. The result is a vector that points in the direction a perfectly reflected ray would go, based on the incoming vector and the normal of the plane it reflects off.

public static Vector3d Reflect(this Vector3d vector, Vector3d normal)

Parameters

vector Vector3d

The vector to reflect.

normal Vector3d

The normal of the plane to reflect off.

Returns

Vector3d

The reflected vector.

Rotate(Vector3d, Vector3d, FixedQuaternion)

Rotates the vector around a given position using a specified quaternion rotation.

public static Vector3d Rotate(this Vector3d source, Vector3d position, FixedQuaternion rotation)

Parameters

source Vector3d

The vector to rotate.

position Vector3d

The position around which the vector is rotated.

rotation FixedQuaternion

The quaternion representing the rotation.

Returns

Vector3d

The rotated vector.

Sign(Vector3d)

Returns a new Vector3d where each component is the sign of the corresponding input component.

public static Vector3d Sign(this Vector3d value)

Parameters

value Vector3d

The input vector.

Returns

Vector3d

A vector where each component is -1, 0, or 1 based on the sign of the input.

Slerp(Vector3d, Vector3d, Fixed64)

Spherically interpolates between two vectors, moving along the shortest arc on a unit sphere.

public static Vector3d Slerp(this Vector3d start, Vector3d end, Fixed64 amount)

Parameters

start Vector3d

The starting vector.

end Vector3d

The ending vector.

amount Fixed64

Returns

Vector3d

The interpolated vector between the two input vectors.

Remarks

Slerp is used to interpolate between two unit vectors on a sphere, providing smooth rotation. It can be more computationally expensive than linear interpolation (Lerp) but results in smoother, arc-like motion.

ToDegrees(Vector3d)

Converts each component of the vector from radians to degrees.

public static Vector3d ToDegrees(this Vector3d radians)

Parameters

radians Vector3d

The vector with components in radians.

Returns

Vector3d

A new vector with components converted to degrees.

ToRadians(Vector3d)

Converts each component of the vector from degrees to radians.

public static Vector3d ToRadians(this Vector3d degrees)

Parameters

degrees Vector3d

The vector with components in degrees.

Returns

Vector3d

A new vector with components converted to radians.

Transform(Vector3d, Fixed4x4)

Transforms a vector by the given 4x4 matrix, applying rotation, scaling, and translation as defined by the matrix.

public static Vector3d Transform(this Vector3d vector, Fixed4x4 matrix)

Parameters

vector Vector3d

The vector to transform.

matrix Fixed4x4

The transformation matrix.

Returns

Vector3d

The transformed vector.

Remarks

UnclampedLerp(Vector3d, Vector3d, Fixed64)

Linearly interpolates between two vectors without clamping the interpolation factor between 0 and 1.

public static Vector3d UnclampedLerp(this Vector3d start, Vector3d end, Fixed64 amount)

Parameters

start Vector3d
end Vector3d
amount Fixed64

Returns

Vector3d

The interpolated vector.

Remarks

Unlike traditional Lerp, this function allows interpolation factors greater than 1 or less than 0, which means the resulting vector can extend beyond the endpoints.