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
valueVector3dThe 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
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
meVector3dThe current vector.
otherVector3dThe 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(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
valueVector3dThe vector to clamp.
minVector3dThe minimum bounds.
maxVector3dThe 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
Returns
ClampOne(Vector3d)
Clamps each component of the given Vector3d within the specified min and max bounds.
public static Vector3d ClampOne(this Vector3d value)
Parameters
valueVector3dThe 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
Returns
CrossProduct(Vector3d, Vector3d)
Computes the cross product magnitude of this vector with another vector.
public static Fixed64 CrossProduct(this Vector3d lhs, Vector3d rhs)
Parameters
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
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
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
Returns
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
meVector3dThe current vector.
otherVector3dThe 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(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
meVector3dThe current vector.
otherVector3dThe vector to compare against.
allowedDifferenceFixed64The 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
sourceVector3dThe vector to rotate.
positionVector3dThe position around which the vector is rotated.
rotationFixedQuaternionThe 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
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
Returns
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
pointVector3dThe point to project.
planeFixedPlaneThe 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
Returns
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
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
sourceVector3dThe vector to rotate.
positionVector3dThe position around which the vector is rotated.
rotationFixedQuaternionThe 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
valueVector3dThe 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
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
radiansVector3dThe 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
degreesVector3dThe 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
Returns
- Vector3d
The transformed vector.
Remarks
Same as operator *(Vector3d, Fixed4x4).
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
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.