Struct Vector3d
- Namespace
- FixedMathSharp
- Assembly
- FixedMathSharp.dll
Represents a 3D vector with fixed-point precision, supporting a wide range of vector operations such as rotation, scaling, interpolation, and projection.
[MemoryPackable(GenerateType.Object)]
public struct Vector3d : IEquatable<Vector3d>, IComparable<Vector3d>, IEqualityComparer<Vector3d>, ISpanFormattable, IFormattable, IMemoryPackable<Vector3d>, IMemoryPackFormatterRegister
- Implements
-
IMemoryPackable<Vector3d>IMemoryPackFormatterRegister
- Inherited Members
- Extension Methods
Remarks
The Vector3d struct is designed for high-precision applications in 3D space, including games, simulations, and physics engines. It offers essential operations like addition, subtraction, dot product, cross product, distance calculation, and normalization.
FixedMathSharp's canonical 3D basis is +X right, +Y up, and +Z
forward. Direction-named core APIs use that convention; engine-specific naming, basis,
handedness, and matrix semantics should be converted at adapter boundaries.
Use Cases:
- Modeling 3D positions, directions, and velocities with fixed-point precision.
- Performing vector transformations, including rotations using quaternions.
- Calculating distances, angles, projections, and interpolation between vectors.
- Essential for fixed-point math scenarios where floating-point precision isn't suitable.
Constructors
Vector3d(Fixed64, Fixed64, Fixed64)
Initializes a new instance of the Vector3d structure with the specified X, Y, and Z components.
[JsonConstructor]
public Vector3d(Fixed64 x, Fixed64 y, Fixed64 z)
Parameters
xFixed64The value of the X component of the vector.
yFixed64The value of the Y component of the vector.
zFixed64The value of the Z component of the vector.
Vector3d(int, int, int)
Initializes a new instance of the Vector3d structure using integer values for the X, Y, and Z components.
public Vector3d(int xInt, int yInt, int zInt)
Parameters
xIntintThe value of the X component as an integer.
yIntintThe value of the Y component as an integer.
zIntintThe value of the Z component as an integer.
Fields
X
The X component of the vector.
[JsonInclude]
[MemoryPackOrder(0)]
public Fixed64 X
Field Value
Y
The Y component of the vector.
[JsonInclude]
[MemoryPackOrder(1)]
public Fixed64 Y
Field Value
Z
The Z component of the vector.
[JsonInclude]
[MemoryPackOrder(2)]
public Fixed64 Z
Field Value
Properties
Backward
The backward direction vector in the canonical 3D basis (0, 0, -1).
public static Vector3d Backward { get; }
Property Value
Direction
Calculates the forward direction vector from pitch (x) and yaw (y) angles.
[JsonIgnore]
[MemoryPackIgnore]
public Vector3d Direction { get; }
Property Value
Remarks
This is commonly used to determine the direction an object is facing in 3D space, where 'x' represents pitch around the X axis and 'y' represents yaw around the Y axis. At zero pitch and yaw this returns Forward. Positive pitch rotates the forward direction toward Down.
Down
The downward direction vector in the canonical 3D basis (0, -1, 0).
public static Vector3d Down { get; }
Property Value
Forward
The forward direction vector in the canonical 3D basis (0, 0, 1).
public static Vector3d Forward { get; }
Property Value
Remarks
FixedMathSharp defines semantic forward as +Z. Use
CoordinateConvention3d at adapter boundaries when an external API uses
different semantic axes, such as -Z forward or +X forward with +Z up.
IsZero
Are all components of this vector equal to zero?
[JsonIgnore]
[MemoryPackIgnore]
public bool IsZero { get; }
Property Value
this[int]
Gets or sets the component value at the specified index.
[JsonIgnore]
[MemoryPackIgnore]
public Fixed64 this[int index] { get; set; }
Parameters
indexintThe zero-based index of the component to access. Valid values are 0 (x), 1 (y), or 2 (z).
Property Value
- Fixed64
The value of the component at the specified index.
Remarks
Use this indexer to access or modify the x, y, or z components of the vector by index. Index 0 corresponds to x, 1 to y, and 2 to z.
Exceptions
- IndexOutOfRangeException
Thrown if index is less than 0 or greater than 2.
Left
The left direction vector in the canonical 3D basis (-1, 0, 0).
public static Vector3d Left { get; }
Property Value
LeftHandNormal
Provides a rotated version of the current vector, where rotation is a 90 degrees rotation around the Y axis in the clockwise direction.
[JsonIgnore]
[MemoryPackIgnore]
public Vector3d LeftHandNormal { get; }
Property Value
LongStateHash
Returns a long hash of the vector based on its x, y, and z values.
[JsonIgnore]
[MemoryPackIgnore]
public long LongStateHash { get; }
Property Value
Magnitude
Returns the actual length of this vector (RO).
[JsonIgnore]
[MemoryPackIgnore]
public Fixed64 Magnitude { get; }
Property Value
MagnitudeSquared
This vector's squared magnitude (aka length squared). If you're doing distance checks, use MagnitudeSquared and square the distance you're checking against. If you need to know the actual distance, use Magnitude.
[JsonIgnore]
[MemoryPackIgnore]
public Fixed64 MagnitudeSquared { get; }
Property Value
- Fixed64
The magnitude.
Negative
(-1, -1, -1)
public static Vector3d Negative { get; }
Property Value
Normalized
Normalizes the given vector, returning a unit vector with the same direction.
[JsonIgnore]
[MemoryPackIgnore]
public Vector3d Normalized { get; }
Property Value
- Vector3d
A normalized (unit) vector with the same direction.
One
(1, 1, 1)
public static Vector3d One { get; }
Property Value
Right
The right direction vector in the canonical 3D basis (1, 0, 0).
public static Vector3d Right { get; }
Property Value
RightHandNormal
Provides a rotated version of the current vector, where rotation is a 90 degrees rotation around the Y axis in the counter-clockwise direction.
[JsonIgnore]
[MemoryPackIgnore]
public Vector3d RightHandNormal { get; }
Property Value
Remarks
These operations rotate the vector 90 degrees around the Y-axis. Note that the positive direction of rotation is defined by the right-hand rule: If your right hand's thumb points in the positive Y direction, then your fingers curl in the positive direction of rotation.
StateHash
Returns a hash of the vector based on its state.
[JsonIgnore]
[MemoryPackIgnore]
public int StateHash { get; }
Property Value
Up
The upward direction vector in the canonical 3D basis (0, 1, 0).
public static Vector3d Up { get; }
Property Value
Zero
(0, 0, 0)
public static Vector3d Zero { get; }
Property Value
Methods
Abs(Vector3d)
Returns a new Vector3d where each component is the absolute value of the corresponding input component.
public static Vector3d Abs(Vector3d value)
Parameters
valueVector3dThe input vector.
Returns
- Vector3d
A vector with absolute values for each component.
Add(Vector3d, Vector3d)
Adds two vectors component-wise.
public static Vector3d Add(Vector3d v1, Vector3d v2)
Parameters
Returns
AddInPlace(Fixed64)
Adds the specified values to the components of the vector in place and returns the modified vector.
public Vector3d AddInPlace(Fixed64 amount)
Parameters
amountFixed64The amount to add to the components.
Returns
- Vector3d
The modified vector after addition.
AddInPlace(Fixed64, Fixed64, Fixed64)
Adds the specified values to the components of the vector in place and returns the modified vector.
public Vector3d AddInPlace(Fixed64 xAmount, Fixed64 yAmount, Fixed64 zAmount)
Parameters
xAmountFixed64The amount to add to the x component.
yAmountFixed64The amount to add to the y component.
zAmountFixed64The amount to add to the z component.
Returns
AddInPlace(Vector3d)
Adds the specified vector components to the corresponding components of the in place vector and returns the modified vector.
public Vector3d AddInPlace(Vector3d other)
Parameters
otherVector3dThe other vector to add the components.
Returns
AllComponentsGreaterThanEpsilon()
Checks whether all components are strictly greater than Epsilon.
public bool AllComponentsGreaterThanEpsilon()
Returns
Angle(Vector3d, Vector3d)
Computes the angle in degrees between two vectors.
public static Fixed64 Angle(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.
AreAlmostParallel(Vector3d, Vector3d, Fixed64)
Determines if two vectors are approximately parallel based on a cosine similarity threshold.
public static bool AreAlmostParallel(Vector3d v1, Vector3d v2, Fixed64 cosThreshold)
Parameters
v1Vector3dThe first normalized vector.
v2Vector3dThe second normalized vector.
cosThresholdFixed64The cosine similarity threshold for near-parallel vectors.
Returns
- bool
True if the vectors are nearly parallel, false otherwise.
AreParallel(Vector3d, Vector3d)
Determines if two vectors are exactly parallel by checking if their cross product is zero.
public static bool AreParallel(Vector3d v1, Vector3d v2)
Parameters
Returns
- bool
True if the vectors are exactly parallel, false otherwise.
BarycentricCoordinates(Vector3d, Vector3d, Vector3d, Fixed64, Fixed64)
Calculates the barycentric coordinates of a point with respect to a triangle defined by three vertices.
public static Vector3d BarycentricCoordinates(Vector3d coordA, Vector3d coordB, Vector3d coordC, Fixed64 weightB, Fixed64 weightC)
Parameters
coordAVector3dThe first vertex of the triangle.
coordBVector3dThe second vertex of the triangle.
coordCVector3dThe third vertex of the triangle.
weightBFixed64The barycentric weight for the second vertex.
weightCFixed64The barycentric weight for the third vertex.
Returns
- Vector3d
The cartesian translation represented by the barycentric coordinates within the triangle.
CatmullRom(Vector3d, Vector3d, Vector3d, Vector3d, Fixed64)
Calculates a position between four points using Catmull-Rom interpolation.
public static Vector3d CatmullRom(Vector3d value1, Vector3d value2, Vector3d value3, Vector3d value4, Fixed64 amount)
Parameters
value1Vector3dThe first point.
value2Vector3dThe second point.
value3Vector3dThe third point.
value4Vector3dThe fourth point.
amountFixed64The interpolation factor.
Returns
- Vector3d
The interpolated position.
Clamp(Vector3d, Vector3d, Vector3d)
Clamps each component of the given Vector3d within the specified min and max bounds.
public static Vector3d Clamp(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(Vector3d value, Fixed64 maxMagnitude)
Parameters
Returns
ClosestPointOnLineSegment(Vector3d, Vector3d, Vector3d)
Calculates the closest point on a line segment defined by start and end points to a given point in space.
public static Vector3d ClosestPointOnLineSegment(Vector3d point, Vector3d start, Vector3d end)
Parameters
pointVector3dThe point to project onto the segment.
startVector3dThe start of the line segment.
endVector3dThe end of the line segment.
Returns
- Vector3d
The closest point on the line segment to the given point.
Remarks
Endpoint differences and projection products are evaluated across the
complete raw domain before the parameter is clamped and rounded.
A direction whose exact Q64.64 squared-length total is at most 2^31 raw
units rounds to zero in Q32.32 and returns start.
CompareDistanceSquared(Vector3d, Vector3d, Vector3d, Vector3d)
Compares the exact squared distances between two pairs of points without fixed-point saturation.
public static int CompareDistanceSquared(Vector3d leftStart, Vector3d leftEnd, Vector3d rightStart, Vector3d rightEnd)
Parameters
Returns
- int
A negative value when the left distance is shorter, zero when the distances are equal, or a positive value when the left distance is longer.
CompareMagnitudeSquared(Vector3d, Vector3d)
Compares the exact squared magnitudes of two vectors without fixed-point saturation.
public static int CompareMagnitudeSquared(Vector3d left, Vector3d right)
Parameters
Returns
- int
A negative value when
leftis shorter, zero when the magnitudes are equal, or a positive value whenleftis longer.
CompareProjection(Vector3d, Vector3d, Vector3d)
Compares the exact component-difference projections of two vectors.
public static int CompareProjection(Vector3d candidate, Vector3d current, Vector3d direction)
Parameters
candidateVector3dThe candidate point.
currentVector3dThe point to compare against.
directionVector3dThe projection direction; it need not be normalized.
Returns
- int
A negative value, zero, or a positive value when the candidate projection is respectively less than, equal to, or greater than the current projection.
CompareTo(Vector3d)
Compares the current Vector3d instance with another Vector3d based on their squared magnitudes.
public int CompareTo(Vector3d other)
Parameters
otherVector3dThe Vector3d instance to compare with the current instance.
Returns
- int
A value less than zero if this instance is less than
other; zero if this instance is equal toother; or a value greater than zero if this instance is greater thanother, as determined by their squared magnitudes.
Remarks
This comparison uses the squared magnitude of each vector, which avoids the computational cost of calculating the actual magnitude. Use this method when only relative vector lengths are important.
Cross(Fixed64, Fixed64, Fixed64)
Returns the cross vector of this vector with another vector.
public Vector3d Cross(Fixed64 otherX, Fixed64 otherY, Fixed64 otherZ)
Parameters
Returns
- Vector3d
A new vector representing the cross product.
Cross(Vector3d, Vector3d)
Cross Product of two vectors.
public static Vector3d Cross(Vector3d lhs, Vector3d rhs)
Parameters
Returns
CrossProduct(Fixed64, Fixed64, Fixed64)
Computes the cross product magnitude of this vector with another vector.
public Fixed64 CrossProduct(Fixed64 otherX, Fixed64 otherY, Fixed64 otherZ)
Parameters
otherXFixed64The X component of the other vector.
otherYFixed64The Y component of the other vector.
otherZFixed64The Z component of the other vector.
Returns
- Fixed64
The cross product magnitude.
CrossProduct(Vector3d, Vector3d)
Computes the cross product magnitude of this vector with another vector.
public static Fixed64 CrossProduct(Vector3d lhs, Vector3d rhs)
Parameters
Returns
- Fixed64
The cross product magnitude.
Deconstruct(out Fixed64, out Fixed64, out Fixed64)
Deconstructs the Vector3d into its three Fixed64 components.
public void Deconstruct(out Fixed64 x, out Fixed64 y, out Fixed64 z)
Parameters
Deconstruct(out double, out double, out double)
Deconstructs the Vector3d into its three double components.
public void Deconstruct(out double x, out double y, out double z)
Parameters
Deconstruct(out int, out int, out int)
Deconstructs the Vector3d into its three int components.
public void Deconstruct(out int x, out int y, out int z)
Parameters
Deconstruct(out long, out long, out long)
Deconstructs the Vector3d into its three long components.
public void Deconstruct(out long x, out long y, out long z)
Parameters
Distance(Fixed64, Fixed64, Fixed64)
Computes the distance between this vector and another vector.
public Fixed64 Distance(Fixed64 otherX, Fixed64 otherY, Fixed64 otherZ)
Parameters
otherXFixed64The x component of the other vector.
otherYFixed64The y component of the other vector.
otherZFixed64The z component of the other vector.
Returns
- Fixed64
The distance between the two vectors.
Distance(Vector3d, Vector3d)
Computes the distance between this vector and another vector.
public static Fixed64 Distance(Vector3d start, Vector3d end)
Parameters
Returns
- Fixed64
The distance between the two vectors.
DistanceSquared(Fixed64, Fixed64, Fixed64)
Calculates the squared distance between two vectors, avoiding the need for a square root operation.
public Fixed64 DistanceSquared(Fixed64 otherX, Fixed64 otherY, Fixed64 otherZ)
Parameters
Returns
- Fixed64
The squared 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(Vector3d start, Vector3d end)
Parameters
Returns
- Fixed64
The squared distance between the two vectors.
Divide(Vector3d, Fixed64)
Divides each vector component by the specified scalar.
public static Vector3d Divide(Vector3d value, Fixed64 divisor)
Parameters
Returns
Divide(Vector3d, Vector3d)
Divides each component of the first vector by the corresponding component of the second vector.
public static Vector3d Divide(Vector3d v1, Vector3d v2)
Parameters
Returns
DivideInPlace(Fixed64)
Divides each component of the vector by the specified scalar divisor in place and returns the modified vector.
public Vector3d DivideInPlace(Fixed64 divisor)
Parameters
divisorFixed64
Returns
DivideInPlace(Fixed64, Fixed64, Fixed64)
Divides each component of the vector by the corresponding divisor in place and returns the modified vector.
public Vector3d DivideInPlace(Fixed64 divisorX, Fixed64 divisorY, Fixed64 divisorZ)
Parameters
Returns
DivideInPlace(Vector3d)
Divides each component of the vector by the corresponding component of the given vector in place and returns the modified vector.
public Vector3d DivideInPlace(Vector3d divisor)
Parameters
divisorVector3d
Returns
Dot(Fixed64, Fixed64, Fixed64)
Computes the dot product of this vector with another vector specified by its components.
public Fixed64 Dot(Fixed64 otherX, Fixed64 otherY, Fixed64 otherZ)
Parameters
otherXFixed64The x component of the other vector.
otherYFixed64The y component of the other vector.
otherZFixed64The z component of the other vector.
Returns
- Fixed64
The dot product of the two vectors.
Dot(Vector3d, Vector3d)
Dot Product of two vectors.
public static Fixed64 Dot(Vector3d lhs, Vector3d rhs)
Parameters
Returns
Equals(Vector3d)
public bool Equals(Vector3d other)
Parameters
otherVector3d
Returns
Equals(Vector3d, Vector3d)
public bool Equals(Vector3d x, Vector3d y)
Parameters
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
FromDouble(double, double, double)
Initializes a new instance of the Vector3d structure using the specified X, Y, and Z coordinates as double-precision floating-point values.
public static Vector3d FromDouble(double xDoub, double yDoub, double zDoub)
Parameters
xDoubdoubleThe X coordinate of the vector, specified as a double-precision floating-point value.
yDoubdoubleThe Y coordinate of the vector, specified as a double-precision floating-point value.
zDoubdoubleThe Z coordinate of the vector, specified as a double-precision floating-point value.
Returns
Remarks
This constructor allows for convenient creation of a Vector3d from double values, which are internally converted to the Fixed64 representation used by the structure. Components are converted through FromDouble(double), so non-finite values throw ArgumentOutOfRangeException and finite values outside the Q32.32 range throw OverflowException.
GetDirection(Vector3d, Vector3d)
Returns the normalized direction from start toward
end across the complete coordinate domain.
public static Vector3d GetDirection(Vector3d start, Vector3d end)
Parameters
Returns
Remarks
Equal endpoints return Zero. Endpoint differences are evaluated exactly even when a component cannot be represented by Fixed64.
GetHashCode()
public override int GetHashCode()
Returns
GetHashCode(Vector3d)
public int GetHashCode(Vector3d obj)
Parameters
objVector3d
Returns
GetMagnitude(Vector3d)
Returns the magnitude (length) of this vector.
public static Fixed64 GetMagnitude(Vector3d vector)
Parameters
vectorVector3dThe vector whose magnitude is being calculated.
Returns
- Fixed64
The magnitude of the vector.
GetNormalized(Vector3d)
Normalizes the given vector, returning a unit vector with the same direction.
public static Vector3d GetNormalized(Vector3d value)
Parameters
valueVector3dThe vector to normalize.
Returns
- Vector3d
A normalized (unit) vector with the same direction.
GetNormalizedProjectionOnPlane(Vector3d, Vector3d)
Returns the normalized direction of a vector projected onto a plane.
public static Vector3d GetNormalizedProjectionOnPlane(Vector3d vector, Vector3d planeNormal)
Parameters
Returns
Remarks
The rejection is formed exactly with full-domain intermediates before returning its nearest representable normalized direction. A zero normal returns the normalized input vector; a zero projection returns Zero.
HermiteSpline(Vector3d, Vector3d, Vector3d, Vector3d, Fixed64)
Calculates a position between two points using Hermite spline interpolation, which takes into account the tangents at the endpoints for smoother transitions.
public static Vector3d HermiteSpline(Vector3d value1, Vector3d tangent1, Vector3d value2, Vector3d tangent2, Fixed64 amount)
Parameters
value1Vector3dThe first point.
tangent1Vector3dThe tangent at the first point.
value2Vector3dThe second point.
tangent2Vector3dThe tangent at the second point.
amountFixed64The interpolation factor.
Returns
- Vector3d
The interpolated position.
InverseRotate(Vector3d, Vector3d, FixedQuaternion)
Applies the inverse of a specified quaternion rotation to the vector around a given position.
public static Vector3d InverseRotate(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.
IsNormalized()
Checks whether the nonzero squared magnitude is within Epsilon of 1.
public bool IsNormalized()
Returns
Lerp(Vector3d, Vector3d, Fixed64)
Linearly interpolates between two points.
public static Vector3d Lerp(Vector3d a, Vector3d b, Fixed64 mag)
Parameters
aVector3dStart value, returned when t = 0.
bVector3dEnd value, returned when t = 1.
magFixed64Value used to interpolate between a and b.
Returns
- Vector3d
Interpolated value, equals to a + (b - a) * t.
Max(Vector3d, Vector3d)
Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors.
public static Vector3d Max(Vector3d value1, Vector3d value2)
Parameters
Returns
- Vector3d
The maximized vector.
Midpoint(Vector3d, Vector3d)
Computes the midpoint between two vectors.
public static Vector3d Midpoint(Vector3d v1, Vector3d v2)
Parameters
Returns
- Vector3d
The midpoint vector.
Min(Vector3d, Vector3d)
Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors.
public static Vector3d Min(Vector3d value1, Vector3d value2)
Parameters
Returns
- Vector3d
The minimized vector.
Multiply(Vector3d, Fixed64)
Multiplies each vector component by the specified scalar.
public static Vector3d Multiply(Vector3d value, Fixed64 factor)
Parameters
Returns
Multiply(Vector3d, Vector3d)
Multiplies two vectors component-wise.
public static Vector3d Multiply(Vector3d v1, Vector3d v2)
Parameters
Returns
MultiplyInPlace(Fixed64)
Multiplies the components of the vector by the specified scalar factor in place and returns the modified vector.
public Vector3d MultiplyInPlace(Fixed64 factor)
Parameters
factorFixed64The scalar factor to multiply each component by.
Returns
MultiplyInPlace(Fixed64, Fixed64, Fixed64)
Multiplies each component of the vector by the corresponding factor in place and returns the modified vector.
public Vector3d MultiplyInPlace(Fixed64 factorX, Fixed64 factorY, Fixed64 factorZ)
Parameters
Returns
MultiplyInPlace(Vector3d)
Multiplies each component of the vector by the corresponding component of the given vector in place and returns the modified vector.
public Vector3d MultiplyInPlace(Vector3d factor)
Parameters
factorVector3dThe vector containing the multiplication factors for each component.
Returns
Negate(Vector3d)
Returns a vector that is the negation of the specified vector, effectively reversing its direction.
public static Vector3d Negate(Vector3d value)
Parameters
valueVector3d
Returns
NormalizeInPlace()
Normalizes this vector in place, making its magnitude (length) equal to 1, and returns the modified vector.
public Vector3d NormalizeInPlace()
Returns
- Vector3d
The normalized vector.
Remarks
If the vector is zero-length or already normalized, no operation is performed. This method modifies the current vector in place and supports method chaining.
NormalizeInPlace(out Fixed64)
Normalizes this vector in place and outputs its original magnitude.
public Vector3d NormalizeInPlace(out Fixed64 mag)
Parameters
magFixed64
Returns
Remarks
If the vector is zero-length or already normalized, no operation is performed, but the original magnitude will still be output.
Project(Vector3d, Vector3d)
Projects a vector onto another vector.
public static Vector3d Project(Vector3d vector, Vector3d onNormal)
Parameters
Returns
ProjectNonNegativeDifference(Vector3d, Vector3d, Vector3d)
Projects target minus source onto a direction
without intermediate saturation, then returns a conservative nonnegative result.
public static Fixed64 ProjectNonNegativeDifference(Vector3d target, Vector3d source, Vector3d direction)
Parameters
targetVector3dThe target point.
sourceVector3dThe source point.
directionVector3dThe projection direction; it need not be normalized.
Returns
- Fixed64
Zero for a nonpositive projection, the positive projection floored to Q32.32, or MaxValue when only the final result is unrepresentable.
ProjectNonNegativeDifferenceParameter(Vector3d, Vector3d, Vector3d)
Projects target minus source onto
direction and returns the nonnegative parametric
coordinate along that direction.
public static Fixed64 ProjectNonNegativeDifferenceParameter(Vector3d target, Vector3d source, Vector3d direction)
Parameters
Returns
Remarks
Unlike ProjectNonNegativeDifference(Vector3d, Vector3d, Vector3d), this method divides the exact dot product by the direction's exact squared length. The direction therefore need not have an exactly unit squared length. Zero and negative projections return zero; an unrepresentable positive parameter saturates to MaxValue.
ProjectOnPlane(Vector3d, FixedPlane)
Projects a point onto a plane defined by a normal and a distance from the origin.
public static Vector3d ProjectOnPlane(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(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(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(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.
ScalarTripleProductSign(Vector3d, Vector3d, Vector3d)
Returns the exact sign of the scalar triple product without fixed-point saturation.
public static int ScalarTripleProductSign(Vector3d first, Vector3d second, Vector3d third)
Parameters
Returns
- int
1for a positive product,-1for a negative product, or0when the vectors are exactly coplanar.
Set(Fixed64, Fixed64, Fixed64)
Set x, y and z components of an existing Vector3.
public Vector3d Set(Fixed64 newX, Fixed64 newY, Fixed64 newZ)
Parameters
Returns
Sign(Vector3d)
Returns a new Vector3d where each component is the sign of the corresponding input component.
public static Vector3d Sign(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(Vector3d start, Vector3d end, Fixed64 percent)
Parameters
startVector3dThe starting vector.
endVector3dThe ending vector.
percentFixed64A value between 0 and 1 that represents the interpolation amount. 0 returns the start vector, and 1 returns the end vector.
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.
SmoothStep(Vector3d, Vector3d, Fixed64)
Calculates a position between two points using a cubic Hermite interpolation, which is similar to HermiteSpline but assumes zero tangents at the endpoints for a smoother curve.
public static Vector3d SmoothStep(Vector3d value1, Vector3d value2, Fixed64 amount)
Parameters
value1Vector3dThe first point.
value2Vector3dThe second point.
amountFixed64The interpolation factor.
Returns
- Vector3d
The interpolated position.
SnapSmallComponentsToZero(Fixed64?)
Returns a new vector with components whose absolute values are less than the specified threshold set to zero.
public Vector3d SnapSmallComponentsToZero(Fixed64? threshold = null)
Parameters
thresholdFixed64?The minimum absolute value a component must have to be retained. If null, a default epsilon value is used.
Returns
- Vector3d
A new Vector3d instance with small components snapped to zero based on the specified threshold.
Remarks
This method is useful for eliminating insignificant floating-point errors by zeroing out very small vector components. The default threshold is suitable for most cases where near-zero values are considered noise.
SpeedLerp(Vector3d, Vector3d, Fixed64, Fixed64)
Moves from a to b at some speed dependent of a delta time with out passing b.
public static Vector3d SpeedLerp(Vector3d a, Vector3d b, Fixed64 speed, Fixed64 dt)
Parameters
Returns
Subtract(Vector3d, Vector3d)
Subtracts two vectors component-wise.
public static Vector3d Subtract(Vector3d v1, Vector3d v2)
Parameters
Returns
SubtractInPlace(Fixed64)
Subtracts the specified value from all components of the vector in place and returns the modified vector.
public Vector3d SubtractInPlace(Fixed64 amount)
Parameters
amountFixed64The amount to subtract from each component.
Returns
SubtractInPlace(Fixed64, Fixed64, Fixed64)
Subtracts the specified values from the components of the vector in place and returns the modified vector.
public Vector3d SubtractInPlace(Fixed64 xAmount, Fixed64 yAmount, Fixed64 zAmount)
Parameters
xAmountFixed64The amount to subtract from the x component.
yAmountFixed64The amount to subtract from the y component.
zAmountFixed64The amount to subtract from the z component.
Returns
SubtractInPlace(Vector3d)
Subtracts the specified vector from the components of the vector in place and returns the modified vector.
public Vector3d SubtractInPlace(Vector3d other)
Parameters
otherVector3d
Returns
ToDegrees(Vector3d)
Converts each component of the vector from radians to degrees.
public static Vector3d ToDegrees(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(Vector3d degrees)
Parameters
degreesVector3dThe vector with components in degrees.
Returns
- Vector3d
A new vector with components converted to radians.
ToString()
Returns a string that represents the current object in the format "(x, y, z)".
public override string ToString()
Returns
- string
A string representation of the object, displaying the x, y, and z values in a formatted tuple.
ToString(string?, IFormatProvider?)
Returns a string that represents the current object in the format "(x, y, z)".
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringformatProviderIFormatProvider
Returns
ToVector2d()
Converts this Vector3d to a Vector2d, dropping the Y component (height) of this vector in the resulting vector.
public Vector2d ToVector2d()
Returns
ToVector4d(Fixed64)
public Vector4d ToVector4d(Fixed64 w)
Parameters
wFixed64
Returns
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(Vector3d vector, Fixed4x4 matrix)
Parameters
Returns
- Vector3d
The transformed vector.
Remarks
Same as operator *(Vector3d, Fixed4x4).
TryAdd(Vector3d, Vector3d, out Vector3d)
Attempts to add two vectors without component saturation.
public static bool TryAdd(Vector3d left, Vector3d right, out Vector3d result)
Parameters
leftVector3dThe left operand.
rightVector3dThe right operand.
resultVector3dThe exact component-wise sum when every component is representable; otherwise, default.
Returns
TryAddSubtract(Vector3d, Vector3d, Vector3d, out Vector3d)
Attempts to add two vectors and subtract a third component-wise without intermediate saturation.
public static bool TryAddSubtract(Vector3d firstAddend, Vector3d secondAddend, Vector3d subtrahend, out Vector3d result)
Parameters
firstAddendVector3dThe first addend.
secondAddendVector3dThe second addend.
subtrahendVector3dThe vector to subtract from the exact component-wise sum.
resultVector3dThe exact component-wise result when every component is representable; otherwise, default.
Returns
TryComposeScaledLocalPoints(Vector3d, Vector3d, Vector3d, Vector3d, Vector3d, FixedQuaternion, out Vector3d)
Attempts to compose two component-scaled offsets in a shared frame and one rotated inner-frame displacement with one final round-half-to-even conversion per component.
public static bool TryComposeScaledLocalPoints(Vector3d outerLocalPoint, Vector3d outerScale, Vector3d innerFrameOffset, Vector3d innerFrameScale, Vector3d innerLocalDisplacement, FixedQuaternion innerRotation, out Vector3d result)
Parameters
outerLocalPointVector3douterScaleVector3dinnerFrameOffsetVector3dinnerFrameScaleVector3dinnerLocalDisplacementVector3dinnerRotationFixedQuaternionresultVector3d
Returns
Remarks
Computes
outerScale * outerLocalPoint
- innerFrameScale * innerFrameOffset
- Rotate(innerLocalDisplacement) without narrowing either scaled offset or the rotated displacement independently.
TryCross(Vector3d, Vector3d, out Vector3d)
Attempts to calculate the cross product with one final round-half-to-even conversion per component.
public static bool TryCross(Vector3d left, Vector3d right, out Vector3d result)
Parameters
Returns
TryDot(Vector3d, Vector3d, out Fixed64)
Attempts to calculate the dot product with one final round-half-to-even conversion.
public static bool TryDot(Vector3d left, Vector3d right, out Fixed64 result)
Parameters
Returns
TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)
Formats this vector into the provided destination buffer.
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Parameters
destinationSpan<char>charsWrittenintformatReadOnlySpan<char>providerIFormatProvider
Returns
TryGetDistance(Vector3d, Vector3d, out Fixed64)
Attempts to return the distance between two endpoints without saturating any component difference.
public static bool TryGetDistance(Vector3d start, Vector3d end, out Fixed64 distance)
Parameters
startVector3dThe first endpoint.
endVector3dThe second endpoint.
distanceFixed64The rounded distance, or MaxValue when it is not representable.
Returns
TryGetMagnitude(Vector3d, out Fixed64)
Attempts to return the magnitude of the given vector without saturating the result.
public static bool TryGetMagnitude(Vector3d vector, out Fixed64 magnitude)
Parameters
vectorVector3dThe vector to measure.
magnitudeFixed64The magnitude, or MaxValue when it is not representable.
Returns
TryGetMagnitudeCeiling(out Fixed64)
Attempts to return this vector's magnitude rounded outward to the smallest containing Q32.32 value.
public readonly bool TryGetMagnitudeCeiling(out Fixed64 magnitude)
Parameters
magnitudeFixed64
Returns
TryGetWeightedAverage(ReadOnlySpan<Vector3d>, ReadOnlySpan<Fixed64>, out Vector3d)
Attempts to calculate the exact non-negative weighted average with one final round-half-to-even conversion per component.
public static bool TryGetWeightedAverage(ReadOnlySpan<Vector3d> values, ReadOnlySpan<Fixed64> weights, out Vector3d average)
Parameters
valuesReadOnlySpan<Vector3d>weightsReadOnlySpan<Fixed64>averageVector3d
Returns
Remarks
Zero-weight values are ignored. The operation returns false only when the total weight is zero.
TryLinearCombination(Vector3d, Fixed64, Vector3d, Fixed64, Vector3d, Fixed64, out Vector3d)
Attempts to combine three scaled vectors with one final round-half-to-even conversion per component.
public static bool TryLinearCombination(Vector3d first, Fixed64 firstScale, Vector3d second, Fixed64 secondScale, Vector3d third, Fixed64 thirdScale, out Vector3d result)
Parameters
firstVector3dfirstScaleFixed64secondVector3dsecondScaleFixed64thirdVector3dthirdScaleFixed64resultVector3d
Returns
TryLinearCombination(Vector3d, Fixed64, Vector3d, Fixed64, out Vector3d)
Attempts to combine two scaled vectors with one final round-half-to-even conversion per component.
public static bool TryLinearCombination(Vector3d first, Fixed64 firstScale, Vector3d second, Fixed64 secondScale, out Vector3d result)
Parameters
Returns
TryScaledLinearCombination(Vector3d, Fixed64, Vector3d, Fixed64, Vector3d, Fixed64, Fixed64, out Vector3d)
Attempts to combine three scaled vectors, apply a final scale, and round each completed component once.
public static bool TryScaledLinearCombination(Vector3d first, Fixed64 firstScale, Vector3d second, Fixed64 secondScale, Vector3d third, Fixed64 thirdScale, Fixed64 resultScale, out Vector3d result)
Parameters
firstVector3dfirstScaleFixed64secondVector3dsecondScaleFixed64thirdVector3dthirdScaleFixed64resultScaleFixed64resultVector3d
Returns
TrySubtract(Vector3d, Vector3d, out Vector3d)
Attempts to subtract two vectors without component saturation.
public static bool TrySubtract(Vector3d left, Vector3d right, out Vector3d result)
Parameters
leftVector3dThe left operand.
rightVector3dThe right operand.
resultVector3dThe exact component-wise difference when every component is representable; otherwise, default.
Returns
TrySubtractSums(Vector3d, Vector3d, Vector3d, Vector3d, out Vector3d)
Attempts to compute (firstLeft + firstRight) -
(secondLeft + secondRight) component-wise without intermediate
saturation.
public static bool TrySubtractSums(Vector3d firstLeft, Vector3d firstRight, Vector3d secondLeft, Vector3d secondRight, out Vector3d result)
Parameters
Returns
UnclampedLerp(Vector3d, Vector3d, Fixed64)
Linearly interpolates between two vectors without clamping the interpolation factor between 0 and 1.
public static Vector3d UnclampedLerp(Vector3d a, Vector3d b, Fixed64 t)
Parameters
aVector3dThe start vector.
bVector3dThe end vector.
tFixed64The interpolation factor. Values outside the range [0, 1] will cause the interpolation to go beyond the start or end points.
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.
Operators
operator +(Fixed64, Vector3d)
Adds a scalar value to each component of the specified vector and returns the resulting vector.
public static Vector3d operator +(Fixed64 mag, Vector3d v1)
Parameters
magFixed64The scalar value to add to each component of the vector.
v1Vector3dThe vector to which the scalar value will be added.
Returns
- Vector3d
A new Vector3d whose components are the sum of the corresponding components of the input vector and the scalar value.
operator +(Vector3d, Fixed64)
Adds a scalar value to each component of the specified vector and returns the resulting vector.
public static Vector3d operator +(Vector3d v1, Fixed64 mag)
Parameters
v1Vector3dThe vector to which the scalar value will be added.
magFixed64The scalar value to add to each component of the vector.
Returns
- Vector3d
A new Vector3d whose components are the sum of the corresponding components of the input vector and the scalar value.
operator +(Vector3d, Vector3d)
Adds two Vector3d instances component-wise.
public static Vector3d operator +(Vector3d v1, Vector3d v2)
Parameters
Returns
- Vector3d
A new Vector3d whose components are the sum of the corresponding components of v1 and v2.
operator +(Vector3d, (int x, int y, int z))
Adds a Vector3d instance to a tuple representing x, y, and z components and returns the resulting vector.
public static Vector3d operator +(Vector3d v1, (int x, int y, int z) v2)
Parameters
v1Vector3dThe first vector to add.
v2(int x, int y, int z)A tuple containing the x, y, and z values to add to the vector.
Returns
- Vector3d
A new Vector3d that is the sum of the original vector and the specified tuple components.
operator +((int x, int y, int z), Vector3d)
Adds a 3-tuple of integers to a Vector3d instance, returning the resulting vector.
public static Vector3d operator +((int x, int y, int z) v2, Vector3d v1)
Parameters
v2(int x, int y, int z)A tuple containing the X, Y, and Z components to add to the vector.
v1Vector3dThe Vector3d instance to which the tuple components are added.
Returns
- Vector3d
A new Vector3d representing the sum of the original vector and the specified tuple components.
operator /(Vector3d, Fixed64)
Divides each component of a vector by a specified scalar value.
public static Vector3d operator /(Vector3d v1, Fixed64 div)
Parameters
v1Vector3dThe vector whose components are to be divided.
divFixed64The scalar value by which to divide each component of the vector.
Returns
- Vector3d
A new vector whose components are the result of dividing the corresponding components of the input vector by the specified scalar. Returns a zero vector if the scalar is zero.
Remarks
If the scalar value is zero, the result is a zero vector to avoid division by zero.
operator /(Vector3d, Vector3d)
Divides each component of one vector by the corresponding component of another vector.
public static Vector3d operator /(Vector3d v1, Vector3d v2)
Parameters
v1Vector3dThe vector whose components are to be divided (the dividend).
v2Vector3dThe vector whose components are used as divisors.
Returns
- Vector3d
A new Vector3d whose components are the result of dividing the corresponding components of v1 by v2. If a component of v2 is zero, the corresponding result component is set to zero.
Remarks
Division by zero for any component in v2 results in a zero value for the corresponding component in the result vector.
operator /(Vector3d, int)
Divides each component of a vector by the specified integer value.
public static Vector3d operator /(Vector3d v1, int div)
Parameters
v1Vector3dThe vector whose components are to be divided.
divintThe integer divisor. If zero, the result is a zero vector.
Returns
- Vector3d
A new vector whose components are the result of dividing each component of the input vector by the specified divisor. Returns a zero vector if the divisor is zero.
operator ==(Vector3d, Vector3d)
Determines whether two Vector3d instances are equal.
public static bool operator ==(Vector3d left, Vector3d right)
Parameters
Returns
operator >(Vector3d, Vector3d)
Determines whether each component of the left vector is greater than the corresponding component of the right vector.
public static bool operator >(Vector3d left, Vector3d right)
Parameters
Returns
- bool
true if the x, y, and z components of left are all greater than those of right; otherwise, false.
operator >=(Vector3d, Vector3d)
Determines whether each component of the left Vector3d is greater than or equal to the corresponding component of the right Vector3d.
public static bool operator >=(Vector3d left, Vector3d right)
Parameters
Returns
- bool
true if the x, y, and z components of left are each greater than or equal to those of right; otherwise, false.
operator !=(Vector3d, Vector3d)
Determines whether two Vector3d instances are not equal.
public static bool operator !=(Vector3d left, Vector3d right)
Parameters
Returns
operator <(Vector3d, Vector3d)
Determines whether each component of the first Vector3d is less than the corresponding component of the second Vector3d.
public static bool operator <(Vector3d left, Vector3d right)
Parameters
Returns
- bool
true if the x, y, and z components of left are all less than those of right; otherwise, false.
Remarks
This operator performs a component-wise comparison. All components of left must be less than the corresponding components of right for the result to be true.
operator <=(Vector3d, Vector3d)
Determines whether each component of the first Vector3d is less than or equal to the corresponding component of the second Vector3d.
public static bool operator <=(Vector3d left, Vector3d right)
Parameters
Returns
- bool
true if the x, y, and z components of left are each less than or equal to the corresponding components of right; otherwise, false.
operator *(Fixed3x3, Vector3d)
Multiplies a 3x3 matrix by a 3-dimensional vector and returns the resulting vector.
public static Vector3d operator *(Fixed3x3 matrix, Vector3d vector)
Parameters
matrixFixed3x3The 3x3 matrix to multiply.
vectorVector3dThe 3-dimensional vector to be transformed by the matrix.
Returns
- Vector3d
A new Vector3d that is the result of multiplying the specified matrix by the specified vector.
Remarks
This operation applies the linear transformation represented by the matrix to the vector. The multiplication is performed using standard matrix-vector multiplication rules.
operator *(Fixed4x4, Vector3d)
Transforms the specified 3D vector by the given 4x4 matrix using homogeneous coordinates.
public static Vector3d operator *(Fixed4x4 matrix, Vector3d point)
Parameters
matrixFixed4x4The 4x4 matrix to apply to the vector. Must represent a valid transformation.
pointVector3dThe 3D vector to be transformed.
Returns
- Vector3d
A new Vector3d representing the transformed vector after applying the matrix.
Remarks
If the matrix is affine, the transformation is performed without perspective division. For non-affine matrices, the result is divided by the computed w component to account for perspective transformations. If the computed w component is zero, it is treated as one to avoid division by zero.
operator *(Fixed64, Vector3d)
Multiplies the specified vector by a scalar value.
public static Vector3d operator *(Fixed64 mag, Vector3d v1)
Parameters
magFixed64The scalar value by which to multiply each component of the vector.
v1Vector3dThe vector to be scaled.
Returns
- Vector3d
A new vector whose components are the products of the corresponding components of the input vector and the scalar value.
operator *(FixedQuaternion, Vector3d)
Rotates the specified 3D point by the given quaternion.
public static Vector3d operator *(FixedQuaternion rotation, Vector3d point)
Parameters
rotationFixedQuaternionThe quaternion representing the rotation to apply.
pointVector3dThe 3D point to be rotated.
Returns
- Vector3d
A new Vector3d representing the rotated point.
Remarks
This operator applies the rotation to the point as if performing a geometric transformation in 3D space.
operator *(Vector3d, Fixed3x3)
Multiplies a 3x3 matrix by a 3-dimensional vector and returns the resulting vector.
public static Vector3d operator *(Vector3d vector, Fixed3x3 matrix)
Parameters
vectorVector3dThe 3-dimensional vector to be transformed by the matrix.
matrixFixed3x3The 3x3 matrix to multiply.
Returns
- Vector3d
A new Vector3d that is the result of multiplying the specified matrix by the specified vector.
Remarks
This operation applies the linear transformation represented by the matrix to the vector. The multiplication is performed using standard matrix-vector multiplication rules.
operator *(Vector3d, Fixed4x4)
Transforms the specified 3D vector by the given 4x4 matrix using homogeneous coordinates.
public static Vector3d operator *(Vector3d vector, Fixed4x4 matrix)
Parameters
vectorVector3dmatrixFixed4x4The 4x4 matrix to apply to the vector. Must represent a valid transformation.
Returns
- Vector3d
A new Vector3d representing the transformed vector after applying the matrix.
Remarks
If the matrix is affine, the transformation is performed without perspective division. For non-affine matrices, the result is divided by the computed w component to account for perspective transformations. If the computed w component is zero, it is treated as one to avoid division by zero.
operator *(Vector3d, Fixed64)
Multiplies the specified vector by a scalar value.
public static Vector3d operator *(Vector3d v1, Fixed64 mag)
Parameters
v1Vector3dThe vector to be scaled.
magFixed64The scalar value by which to multiply each component of the vector.
Returns
- Vector3d
A new vector whose components are the products of the corresponding components of the input vector and the scalar value.
operator *(Vector3d, FixedQuaternion)
Rotates the specified 3D point by the given quaternion.
public static Vector3d operator *(Vector3d point, FixedQuaternion rotation)
Parameters
pointVector3dThe 3D point to be rotated.
rotationFixedQuaternionThe quaternion representing the rotation to apply.
Returns
- Vector3d
A new Vector3d representing the rotated point.
Remarks
This operator applies the rotation to the point as if performing a geometric transformation in 3D space.
operator *(Vector3d, Vector3d)
Multiplies the corresponding components of two vectors and returns the resulting vector.
public static Vector3d operator *(Vector3d v1, Vector3d v2)
Parameters
Returns
- Vector3d
A new Vector3d whose components are the products of the corresponding components of the input vectors.
Remarks
This operation performs component-wise multiplication, not a dot or cross product. Each component of the result is calculated as the product of the corresponding components of the input vectors.
operator *(Vector3d, int)
Multiplies each component of the specified vector by the given scalar value.
public static Vector3d operator *(Vector3d v1, int mag)
Parameters
v1Vector3dThe vector whose components are to be multiplied.
magintThe scalar value by which to multiply each component of the vector.
Returns
- Vector3d
A new Vector3d whose components are the products of the corresponding components of the input vector and the scalar value.
operator *(int, Vector3d)
Multiplies each component of the specified vector by the given scalar value.
public static Vector3d operator *(int mag, Vector3d v1)
Parameters
magintThe scalar value by which to multiply each component of the vector.
v1Vector3dThe vector whose components are to be multiplied.
Returns
- Vector3d
A new Vector3d whose components are the products of the corresponding components of the input vector and the scalar value.
operator -(Vector3d, Fixed64)
Subtracts the specified scalar value from each component of the given vector.
public static Vector3d operator -(Vector3d v1, Fixed64 mag)
Parameters
v1Vector3dThe vector from which to subtract the scalar value from each component.
magFixed64The scalar value to subtract from each component of the vector.
Returns
- Vector3d
A new Vector3d whose components are the result of subtracting the scalar value from the corresponding components of the input vector.
operator -(Vector3d, Vector3d)
Subtracts the components of one Vector3d from another and returns the resulting vector.
public static Vector3d operator -(Vector3d v1, Vector3d v2)
Parameters
Returns
- Vector3d
A Vector3d whose components are the result of subtracting the corresponding components of v2 from v1.
operator -(Vector3d, (int x, int y, int z))
Subtracts the specified tuple from the given vector and returns the resulting vector.
public static Vector3d operator -(Vector3d v1, (int x, int y, int z) v2)
Parameters
v1Vector3dThe vector from which to subtract the tuple values.
v2(int x, int y, int z)A tuple containing the x, y, and z values to subtract from the vector.
Returns
- Vector3d
A new Vector3d representing the result of subtracting the tuple values from the original vector.
operator -((int x, int y, int z), Vector3d)
Subtracts the components of a specified Vector3d from the corresponding components of a 3-tuple of integers and returns the resulting Vector3d.
public static Vector3d operator -((int x, int y, int z) v1, Vector3d v2)
Parameters
v1(int x, int y, int z)A tuple containing the x, y, and z components to subtract from.
v2Vector3dThe Vector3d whose components are subtracted from the corresponding components of the tuple.
Returns
- Vector3d
A Vector3d whose components are the result of subtracting the components of v2 from the corresponding components of v1.
Remarks
This operator enables direct subtraction between a tuple of three integers and a Vector3d, returning a new Vector3d instance.
operator -(Vector3d)
Negates each component of the specified vector.
public static Vector3d operator -(Vector3d v1)
Parameters
v1Vector3dThe vector whose components are to be negated.
Returns
- Vector3d
A new vector whose components are the negated values of the input vector.