Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ProwlEngine/Prowl.Vector/llms.txt

Use this file to discover all available pages before exploring further.

Double3 is a 3-component vector backed by double-precision (64-bit) floating-point values. It is defined in the Prowl.Vector namespace and marked [Serializable], making it suitable for serialization workflows throughout the Prowl Engine.

Declaration

[Serializable]
public partial struct Double3 : IEquatable<Double3>, IFormattable

Fields

FieldTypeDescription
XdoubleThe X component.
YdoubleThe Y component.
ZdoubleThe Z component.

Static Constants

PropertyValueDescription
Zero(0, 0, 0)The zero vector.
One(1, 1, 1)A vector with all components set to one.
UnitX(1, 0, 0)The unit vector along the X-axis.
UnitY(0, 1, 0)The unit vector along the Y-axis.
UnitZ(0, 0, 1)The unit vector along the Z-axis.

Constructors

SignatureDescription
Double3(double scalar)Sets all three components to scalar.
Double3(double x, double y, double z)Sets X, Y, and Z individually.
Double3(Double3 v)Copy constructor.
Double3(double[] array)Reads components from a double[] of at least length 3.
Double3(IEnumerable<double> values)Reads components from an enumerable of at least 3 elements.
Double3(ReadOnlySpan<double> span)Reads components from a read-only span of at least length 3.
Double3(Span<double> span)Reads components from a span of at least length 3.
Double3(Double2 xy, double z)Constructs from a Double2 for XY and a separate z.
Double3(double x, Double2 yz)Constructs from a separate x and a Double2 for YZ.
Double3(Float3 v)Widens a Float3 to double precision (implicit cast).
Double3(Int3 v)Converts an Int3 to double precision (explicit cast).

Properties

PropertyTypeDescription
this[int index]doubleGets or sets a component by index. 0X, 1Y, 2Z. Throws IndexOutOfRangeException for any other value.

Operators

Arithmetic — vector × vector (component-wise)

OperatorSignatureDescription
+Double3 + Double3Component-wise addition.
-Double3 - Double3Component-wise subtraction.
*Double3 * Double3Component-wise multiplication.
/Double3 / Double3Component-wise division.
%Double3 % Double3Component-wise remainder.

Arithmetic — vector × scalar

OperatorSignatureDescription
+Double3 + double / double + Double3Adds scalar to each component.
-Double3 - double / double - Double3Subtracts scalar from each component (or vice-versa).
*Double3 * double / double * Double3Scales each component.
/Double3 / double / double / Double3Divides each component by scalar (or divides scalar by each component).
%Double3 % double / double % Double3Remainder with scalar.

Unary & comparison

OperatorSignatureDescription
Unary --Double3Negates all three components.
==Double3 == Double3Component-wise equality.
!=Double3 != Double3Component-wise inequality.

Casts

ConversionKindDescription
Float3Double3implicitWidens single-precision to double-precision.
Int3Double3explicitConverts integer components to double.
Double2Double3explicitExtends to 3D with Z = 0.
Double3Double2explicitDrops the Z component.

Static Methods

Geometric

SignatureDescription
static double Dot(Double3 x, Double3 y)Returns the dot product x.X*y.X + x.Y*y.Y + x.Z*y.Z.
static Double3 Cross(Double3 x, Double3 y)Returns the cross product of two 3D vectors (a vector perpendicular to both).
static double Length(Double3 v)Returns the Euclidean length (magnitude) of v.
static double LengthSquared(Double3 v)Returns the squared length; cheaper than Length when only comparison is needed.
static Double3 Normalize(Double3 v)Returns a unit-length copy of v, or Zero if the vector is near-zero.
static double Distance(Double3 x, Double3 y)Returns the Euclidean distance between x and y.
static double DistanceSquared(Double3 x, Double3 y)Returns the squared distance between x and y.
static double AngleBetween(Double3 a, Double3 b)Returns the angle in radians between two vectors.
static double SignedAngleBetween(Double3 a, Double3 b, Double3 axis)Returns the signed angle in radians around axis, following the right-hand rule.
static bool IsParallel(Double3 a, Double3 b, double tolerance = 1e-15)Returns true if the two vectors point in the same or opposite directions within the given tolerance.
static bool IsPerpendicular(Double3 a, Double3 b, double tolerance = 1e-15)Returns true if the dot product is within tolerance of zero.

Orthonormalization

SignatureDescription
static void OrthoNormalize(ref Double3 normal, ref Double3 tangent)Orthonormalizes normal and tangent using the Gram–Schmidt process.
static void OrthoNormalize(ref Double3 normal, ref Double3 tangent, ref Double3 binormal)Orthonormalizes a full TBN (tangent, bitangent, normal) frame.

Interpolation

SignatureDescription
static Double3 Slerp(Double3 a, Double3 b, double t)Spherically interpolates between a and b; t is clamped to [0, 1].
static Double3 SlerpUnclamped(Double3 a, Double3 b, double t)Spherical interpolation without clamping t.
static Double3 MoveTowards(Double3 current, Double3 target, double maxDistanceDelta)Moves current toward target by at most maxDistanceDelta.

Projection & Reflection

SignatureDescription
static Double3 Project(Double3 a, Double3 b)Projects vector a onto vector b.
static Double3 ProjectOntoPlane(Double3 vector, Double3 planeNormal)Removes the component of vector along planeNormal.
static Double3 Reflect(Double3 vector, Double3 normal)Reflects vector off the surface defined by normal.
static Double3 Refract(Double3 incident, Double3 normal, double eta)Computes the refraction direction given an index-of-refraction ratio eta. Returns (0, 0, 0) on total internal reflection.

Swizzles

Double3 exposes the full set of GLSL-style swizzle properties for all 2- and 3-component permutations (auto-generated). Read-write swizzles reassign the underlying components; read-only swizzles (where the same component appears more than once) are computed getters. Examples:
Double3 v = new Double3(1.0, 2.0, 3.0);

Double2 xy  = v.XY;   // (1.0, 2.0) — get/set
Double2 zx  = v.ZX;   // (3.0, 1.0) — get/set
Double3 zyx = v.ZYX;  // (3.0, 2.0, 1.0) — get/set
Double3 xxx = v.XXX;  // (1.0, 1.0, 1.0) — get only

// Setting a swizzle writes back to the source vector
v.YZ = new Double2(10.0, 20.0);  // v is now (1.0, 10.0, 20.0)

Instance Methods

SignatureDescription
double[] ToArray()Returns [X, Y, Z] as a new array.
string ToString()Formats as (X, Y, Z) using the current culture.
string ToString(string format)Formats each component with the given numeric format string.
string ToString(string format, IFormatProvider formatProvider)Fully customizable format output.
bool Equals(Double3 other)Component-wise equality.
int GetHashCode()Combined hash of all three components.

Code Example

using Prowl.Vector;

// Build orthonormal camera basis from a look-at direction and world-up
Double3 forward = Double3.Normalize(new Double3(0.5, -0.3, 1.0));
Double3 worldUp = Double3.UnitY;

Double3 right = Double3.Normalize(Double3.Cross(forward, worldUp));
Double3 up    = Double3.Cross(right, forward);

Console.WriteLine($"Forward : {forward}");
Console.WriteLine($"Right   : {right}");
Console.WriteLine($"Up      : {up}");

// Spherically interpolate between two directions
Double3 start = Double3.UnitX;
Double3 end   = Double3.UnitZ;
Double3 mid   = Double3.Slerp(start, end, 0.5);  // ≈ (0.707, 0, 0.707)

// Reflect a ray off a plane normal
Double3 incident = new Double3(1.0, -1.0, 0.0);
Double3 normal   = Double3.UnitY;
Double3 reflected = Double3.Reflect(incident, normal);  // (1.0, 1.0, 0.0)

Console.WriteLine($"Slerp mid : {mid}");
Console.WriteLine($"Reflected : {reflected}");

Build docs developers (and LLMs) love