reckfellENGINE

Vector3

A three-component value for 3D coordinates and calculations.

On this page
struct Vector3ReckfellSharpInherits ValueType

Distinguish position, displacement, velocity and normal even when all use Vector3. In 3D, Y is up, Forward = (0,0,−1) and Back = (0,0,1). Right.Cross(Up) gives Back. Vector3.One has length √3, not 1.

Normalization removes distance; Zero has no direction. Account for parent space and scale: Transform3D × point includes translation; Basis × vector does not. A normal under nonuniform scale requires inverse-transposed Basis.

Practical guide.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

Vector3Constructor
# Vector3
C#
public Vector3(float x, float y, float z);

Returns a Vector3 with the given components.

Parameters
NameTypeDefault
xfloat—
yfloat—
zfloat—
x

The vector's X component.

y

The vector's Y component.

z

The vector's Z component.

Properties16

BackProperty
# Back
C#
public static Vector3 Back { get; }

Back unit vector. Represents the local direction of back, and the global direction of south.

DownProperty
# Down
C#
public static Vector3 Down { get; }

Down unit vector.

ForwardProperty
# Forward
C#
public static Vector3 Forward { get; }

Forward unit vector. Represents the local direction of forward, and the global direction of north. Keep in mind that the forward direction for lights, cameras, etc is different from 3D assets like characters, which face towards the camera by convention. Use Vector3.ModelFront and similar constants when working in 3D asset space.

InfProperty
# Inf
C#
public static Vector3 Inf { get; }

Infinity vector, a vector with all components set to @C#.INF.

ItemProperty
# Item
C#
public float this[int index] { get; set; }

Access vector components using their index.

LeftProperty
# Left
C#
public static Vector3 Left { get; }

Left unit vector. Represents the local direction of left, and the global direction of west.

ModelBottomProperty
# ModelBottom
C#
public static Vector3 ModelBottom { get; }

Unit vector pointing towards the bottom side (down) of imported 3D assets.

ModelFrontProperty
# ModelFront
C#
public static Vector3 ModelFront { get; }

Unit vector pointing towards the front side (facing forward) of imported 3D assets.

ModelLeftProperty
# ModelLeft
C#
public static Vector3 ModelLeft { get; }

Unit vector pointing towards the left side of imported 3D assets.

ModelRearProperty
# ModelRear
C#
public static Vector3 ModelRear { get; }

Unit vector pointing towards the rear side (back) of imported 3D assets.

ModelRightProperty
# ModelRight
C#
public static Vector3 ModelRight { get; }

Unit vector pointing towards the right side of imported 3D assets.

ModelTopProperty
# ModelTop
C#
public static Vector3 ModelTop { get; }

Unit vector pointing towards the top side (up) of imported 3D assets.

OneProperty
# One
C#
public static Vector3 One { get; }

One vector, a vector with all components set to 1.

RightProperty
# Right
C#
public static Vector3 Right { get; }

Right unit vector. Represents the local direction of right, and the global direction of east.

UpProperty
# Up
C#
public static Vector3 Up { get; }

Up unit vector.

ZeroProperty
# Zero
C#
public static Vector3 Zero { get; }

Zero vector, a vector with all components set to 0.

Methods71

AbsVector3
# Abs
C#
public Vector3 Abs();

Returns a new vector with all components in absolute values (i.e. positive).

Returns Vector3

A vector with Mathf.Abs called on each component.

AngleTofloat
# AngleTo
C#
public float AngleTo(Vector3 to);

Returns the unsigned minimum angle to the given vector, in radians.

Parameters
NameTypeDefault
toVector3—
to

The other vector to compare this vector to.

Returns float

The unsigned angle between the two vectors, in radians.

BezierDerivativeVector3
# BezierDerivative
C#
public Vector3 BezierDerivative(Vector3 control1, Vector3 control2, Vector3 end, float t);

Returns the derivative at the given t on the Bézier curve defined by this vector and the given control_1, control_2, and end points.

Parameters
NameTypeDefault
control1Vector3—
control2Vector3—
endVector3—
tfloat—
control1

Control point that defines the bezier curve.

control2

Control point that defines the bezier curve.

end

The destination value for the interpolation.

t

A value on the range of 0.0 to 1.0, representing the amount of interpolation.

Returns Vector3

The resulting value of the interpolation.

BezierInterpolateVector3
# BezierInterpolate
C#
public Vector3 BezierInterpolate(Vector3 control1, Vector3 control2, Vector3 end, float t);

Returns the point at the given t on the Bézier curve defined by this vector and the given control_1, control_2, and end points.

Parameters
NameTypeDefault
control1Vector3—
control2Vector3—
endVector3—
tfloat—
control1

Control point that defines the bezier curve.

control2

Control point that defines the bezier curve.

end

The destination vector.

t

A value on the range of 0.0 to 1.0, representing the amount of interpolation.

Returns Vector3

The interpolated vector.

BounceVector3
# Bounce
C#
public Vector3 Bounce(Vector3 normal);

Returns the vector "bounced off" from a plane defined by the given normal n. Note: Vector3.Bounce performs the operation that most engines and frameworks call [code skip-lint]reflect()`.

Parameters
NameTypeDefault
normalVector3—
normal

The normal vector defining the plane to bounce off. Must be normalized.

Returns Vector3

The bounced vector.

CeilVector3
# Ceil
C#
public Vector3 Ceil();

Returns a new vector with all components rounded up (towards positive infinity).

Returns Vector3

A vector with Mathf.Ceil called on each component.

Clamp2 overloads
# Clamp · 1/2
C#
public Vector3 Clamp(Vector3 min, Vector3 max);

Returns a new vector with all components clamped between the components of Vector3.Min and Vector3.Max, by running @GlobalScope.clamp on each component.

Parameters
NameTypeDefault
minVector3—
maxVector3—
min

The vector with minimum allowed values.

max

The vector with maximum allowed values.

Returns Vector3

The vector with all components clamped.

# Clamp · 2/2
C#
public Vector3 Clamp(float min, float max);

Returns a new vector with all components clamped between the components of Vector3.Min and Vector3.Max, by running @GlobalScope.clamp on each component.

Parameters
NameTypeDefault
minfloat—
maxfloat—
min

The minimum allowed value.

max

The maximum allowed value.

Returns Vector3

The vector with all components clamped.

CrossVector3
# Cross
C#
public Vector3 Cross(Vector3 with);

Returns a perpendicular vector whose magnitude depends on input lengths and angle. Right.Cross(Up) = Back (+Z); Reckfell Forward is −Z.

Parameters
NameTypeDefault
withVector3—
with

The other vector.

Returns Vector3

The cross product vector.

CubicInterpolateVector3
# CubicInterpolate
C#
public Vector3 CubicInterpolate(Vector3 b, Vector3 preA, Vector3 postB, float weight);

Performs a cubic interpolation between this vector and b using pre_a and post_b as handles, and returns the result at position weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.

Parameters
NameTypeDefault
bVector3—
preAVector3—
postBVector3—
weightfloat—
b

The destination vector.

preA

A vector before this vector.

postB

A vector after b.

weight

A value on the range of 0.0 to 1.0, representing the amount of interpolation.

Returns Vector3

The interpolated vector.

CubicInterpolateInTimeVector3
# CubicInterpolateInTime
C#
public Vector3 CubicInterpolateInTime(Vector3 b, Vector3 preA, Vector3 postB, float weight, float t, float preAT, float postBT);

Performs a cubic interpolation between this vector and b using pre_a and post_b as handles, and returns the result at position weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation. It can perform smoother interpolation than Vector3.CubicInterpolate by the time values.

Parameters
NameTypeDefault
bVector3—
preAVector3—
postBVector3—
weightfloat—
tfloat—
preATfloat—
postBTfloat—
b

The destination vector.

preA

A vector before this vector.

postB

A vector after b.

weight

A value on the range of 0.0 to 1.0, representing the amount of interpolation.

Returns Vector3

The interpolated vector.

Deconstructvoid
# Deconstruct
C#
public void Deconstruct(out float x, out float y, out float z);

Helper method for deconstruction into a tuple.

Parameters
NameTypeDefault
xfloat—
yfloat—
zfloat—
DirectionToVector3
# DirectionTo
C#
public Vector3 DirectionTo(Vector3 to);

Returns the normalized vector pointing from this vector to to. a.direction_to(b) is equivalent to (b - a).normalized(). See also Vector3.Normalized.

Parameters
NameTypeDefault
toVector3—
to

The other vector to point towards.

Returns Vector3

The direction from this vector to to.

DistanceSquaredTofloat
# DistanceSquaredTo
C#
public float DistanceSquaredTo(Vector3 to);

Returns the squared Euclidean distance between this vector and to. This method runs faster than Vector3.DistanceTo, so prefer it if you need to compare vectors or need the squared distance for some formula.

Parameters
NameTypeDefault
toVector3—
to

The other vector to use.

Returns float

The squared distance between the two vectors.

DistanceTofloat
# DistanceTo
C#
public float DistanceTo(Vector3 to);

Returns the Euclidean distance between this vector and to.

Parameters
NameTypeDefault
toVector3—
to

The other vector to use.

Returns float

The distance between the two vectors.

Dotfloat
# Dot
C#
public float Dot(Vector3 with);

Returns the dot product of this vector and with. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player. The dot product will be 0 for a right angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees. When using unit (normalized) vectors, the result will always be between -1.0 (180 degree angle) when the vectors are facing opposite directions, and 1.0 (0 degree angle) when the vectors are aligned. Note: a.dot(b) is equivalent to b.dot(a).

Parameters
NameTypeDefault
withVector3—
with

The other vector to use.

Returns float

The dot product of the two vectors.

Equals2 overloads
# Equals · 1/2
C#
public bool Equals(Vector3 other);

Returns true if the vectors are exactly equal. Note: Due to floating-point precision errors, consider using Vector3.IsEqualApprox instead, which is more reliable.

Parameters
NameTypeDefault
otherVector3—
other

The other vector.

Returns bool

Whether or not the vectors are exactly equal.

# Equals · 2/2
C#
public override bool Equals(object? obj);

Returns true if the vector is exactly equal to the given object (obj). Note: Due to floating-point precision errors, consider using Vector3.IsEqualApprox instead, which is more reliable.

Parameters
NameTypeDefault
objobject—
obj

The object to compare with.

Returns bool

Whether or not the vector and the object are equal.

FloorVector3
# Floor
C#
public Vector3 Floor();

Returns a new vector with all components rounded down (towards negative infinity).

Returns Vector3

A vector with Mathf.Floor called on each component.

GetHashCodeint
# GetHashCode
C#
public override int GetHashCode();

Serves as the hash function for Vector3.

Returns int

A hash code for this vector.

InverseVector3
# Inverse
C#
public Vector3 Inverse();

Returns the inverse of the vector. This is the same as Vector3(1.0 / v.x, 1.0 / v.y, 1.0 / v.z).

Returns Vector3

The inverse of this vector.

IsEqualApproxbool
# IsEqualApprox
C#
public bool IsEqualApprox(Vector3 other);

Returns true if this vector and to are approximately equal, by running @GlobalScope.is_equal_approx on each component.

Parameters
NameTypeDefault
otherVector3—
other

The other vector to compare.

Returns bool

Whether or not the vectors are approximately equal.

IsFinitebool
# IsFinite
C#
public bool IsFinite();

Returns true if this vector is finite, by calling @GlobalScope.is_finite on each component.

Returns bool

Whether this vector is finite or not.

IsNormalizedbool
# IsNormalized
C#
public bool IsNormalized();

Returns true if the vector is normalized, i.e. its length is approximately equal to 1.

Returns bool

A bool indicating whether or not the vector is normalized.

IsZeroApproxbool
# IsZeroApprox
C#
public bool IsZeroApprox();

Returns true if this vector's values are approximately zero, by running @GlobalScope.is_zero_approx on each component. This method is faster than using Vector3.IsEqualApprox with one value as a zero vector.

Returns bool

Whether or not the vector is approximately zero.

Lengthfloat
# Length
C#
public float Length();

Returns the length (magnitude) of this vector.

Returns float

The length of this vector.

LengthSquaredfloat
# LengthSquared
C#
public float LengthSquared();

Returns the squared length (squared magnitude) of this vector. This method runs faster than Vector3.Length, so prefer it if you need to compare vectors or need the squared distance for some formula.

Returns float

The squared length of this vector.

LerpVector3
# Lerp
C#
public Vector3 Lerp(Vector3 to, float weight);

Returns the result of the linear interpolation between this vector and to by amount weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.

Parameters
NameTypeDefault
toVector3—
weightfloat—
to

The destination vector for interpolation.

weight

A value on the range of 0.0 to 1.0, representing the amount of interpolation.

Returns Vector3

The resulting vector of the interpolation.

LimitLengthVector3
# LimitLength
C#
public Vector3 LimitLength(float length = 1f);

Returns the vector with a maximum length by limiting its length to Vector3.Length. If the vector is non-finite, the result is undefined.

Parameters
NameTypeDefault
lengthfloat1f
length

The length to limit to.

Returns Vector3

The vector with its length limited.

Max2 overloads
# Max · 1/2
C#
public Vector3 Max(Vector3 with);

Returns the component-wise maximum of this and with, equivalent to Vector3(maxf(x, with.x), maxf(y, with.y), maxf(z, with.z)).

Parameters
NameTypeDefault
withVector3—
with

The other vector to use.

Returns Vector3

The resulting maximum vector.

# Max · 2/2
C#
public Vector3 Max(float with);

Returns the component-wise maximum of this and with, equivalent to Vector3(maxf(x, with.x), maxf(y, with.y), maxf(z, with.z)).

Parameters
NameTypeDefault
withfloat—
with

The other value to use.

Returns Vector3

The resulting maximum vector.

MaxAxisIndexVector3.Axis
# MaxAxisIndex
C#
public Vector3.Axis MaxAxisIndex();

Returns the axis of the vector's highest value. See AXIS_* constants. If all components are equal, this method returns Vector3.Axis.X.

Returns Vector3.Axis

The index of the highest axis.

Min2 overloads
# Min · 1/2
C#
public Vector3 Min(Vector3 with);

Returns the component-wise minimum of this and with, equivalent to Vector3(minf(x, with.x), minf(y, with.y), minf(z, with.z)).

Parameters
NameTypeDefault
withVector3—
with

The other vector to use.

Returns Vector3

The resulting minimum vector.

# Min · 2/2
C#
public Vector3 Min(float with);

Returns the component-wise minimum of this and with, equivalent to Vector3(minf(x, with.x), minf(y, with.y), minf(z, with.z)).

Parameters
NameTypeDefault
withfloat—
with

The other value to use.

Returns Vector3

The resulting minimum vector.

MinAxisIndexVector3.Axis
# MinAxisIndex
C#
public Vector3.Axis MinAxisIndex();

Returns the axis of the vector's lowest value. See AXIS_* constants. If all components are equal, this method returns Vector3.Axis.Z.

Returns Vector3.Axis

The index of the lowest axis.

MoveTowardVector3
# MoveToward
C#
public Vector3 MoveToward(Vector3 to, float delta);

Returns a new vector moved toward to by the fixed delta amount. Will not go past the final value.

Parameters
NameTypeDefault
toVector3—
deltafloat—
to

The vector to move towards.

delta

The amount to move towards by.

Returns Vector3

The resulting vector.

NormalizedVector3
# Normalized
C#
public Vector3 Normalized();

Returns the result of scaling the vector to unit length. Equivalent to v / v.length(). Returns (0, 0, 0) if v.length() == 0. See also Vector3.IsNormalized. Note: This function may return incorrect values if the input vector length is near zero.

Returns Vector3

A normalized version of the vector.

OctahedronDecodeVector3
# OctahedronDecode
C#
public static Vector3 OctahedronDecode(Vector2 oct);

Returns the Vector3 from an octahedral-compressed form created using Vector3.OctahedronEncode (stored as a Vector2).

Parameters
NameTypeDefault
octVector2—
oct

Encoded Vector2

Returns Vector3

The decoded normalized Vector3.

OctahedronEncodeVector2
# OctahedronEncode
C#
public Vector2 OctahedronEncode();

Returns the octahedral-encoded (oct32) form of this Vector3 as a Vector2. Since a Vector2 occupies 1/3 less memory compared to Vector3, this form of compression can be used to pass greater amounts of Vector3.Normalized Vector3s without increasing storage or memory requirements. See also Vector3.OctahedronDecode. Note: Vector3.OctahedronEncode can only be used for Vector3.Normalized vectors. Vector3.OctahedronEncode does not check whether this Vector3 is normalized, and will return a value that does not decompress to the original value if the Vector3 is not normalized. Note: Octahedral compression is lossy, although visual differences are rarely perceptible in real world scenarios.

Returns Vector2

The encoded Vector2.

OuterBasis
# Outer
C#
public Basis Outer(Vector3 with);

Returns the outer product with with.

Parameters
NameTypeDefault
withVector3—
with

The other vector.

Returns Basis

A Basis representing the outer product matrix.

PosMod2 overloads
# PosMod · 1/2
C#
public Vector3 PosMod(Vector3 modv);

Returns a vector composed of the @GlobalScope.fposmod of this vector's components and mod.

Parameters
NameTypeDefault
modvVector3—
modv

A vector representing the divisors of the operation.

Returns Vector3

A vector with each component Mathf.PosMod by modv's components.

# PosMod · 2/2
C#
public Vector3 PosMod(float mod);

Returns a vector composed of the @GlobalScope.fposmod of this vector's components and mod.

Parameters
NameTypeDefault
modfloat—
mod

A value representing the divisor of the operation.

Returns Vector3

A vector with each component Mathf.PosMod by mod.

ProjectVector3
# Project
C#
public Vector3 Project(Vector3 onNormal);

Returns a new vector resulting from projecting this vector onto the given vector b. The resulting new vector is parallel to b. See also Vector3.Slide. Note: If the vector b is a zero vector, the components of the resulting new vector will be @C#.NAN.

Parameters
NameTypeDefault
onNormalVector3—
onNormal

The vector to project onto.

Returns Vector3

The projected vector.

ReflectVector3
# Reflect
C#
public Vector3 Reflect(Vector3 normal);

Returns the result of reflecting the vector through a plane defined by the given normal vector n. Note: Vector3.Reflect differs from what other engines and frameworks call Vector3.Bounce which does what most engines call [code skip-lint]reflect()`.

Parameters
NameTypeDefault
normalVector3—
normal

The normal vector defining the plane to reflect from. Must be normalized.

Returns Vector3

The reflected vector.

RotatedVector3
# Rotated
C#
public Vector3 Rotated(Vector3 axis, float angle);

Returns the result of rotating this vector around a given axis by angle (in radians). The axis must be a normalized vector. See also @GlobalScope.deg_to_rad.

Parameters
NameTypeDefault
axisVector3—
anglefloat—
axis

The vector to rotate around. Must be normalized.

angle

The angle to rotate by, in radians.

Returns Vector3

The rotated vector.

RoundVector3
# Round
C#
public Vector3 Round();

Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.

Returns Vector3

The rounded vector.

SignVector3
# Sign
C#
public Vector3 Sign();

Returns a new vector with each component set to 1.0 if it's positive, -1.0 if it's negative, and 0.0 if it's zero. The result is identical to calling @GlobalScope.sign on each component.

Returns Vector3

A vector with all components as either 1, -1, or 0.

SignedAngleTofloat
# SignedAngleTo
C#
public float SignedAngleTo(Vector3 to, Vector3 axis);

Returns the signed angle to the given vector, in radians. The sign of the angle is positive in a counter-clockwise direction and negative in a clockwise direction when viewed from the side specified by the axis.

Parameters
NameTypeDefault
toVector3—
axisVector3—
to

The other vector to compare this vector to.

axis

The reference axis to use for the angle sign.

Returns float

The signed angle between the two vectors, in radians.

SlerpVector3
# Slerp
C#
public Vector3 Slerp(Vector3 to, float weight);

Returns the result of spherical linear interpolation between this vector and to, by amount weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation. This method also handles interpolating the lengths if the input vectors have different lengths. For the special case of one or both input vectors having zero length, this method behaves like Vector3.Lerp.

Parameters
NameTypeDefault
toVector3—
weightfloat—
to

The destination vector for interpolation.

weight

A value on the range of 0.0 to 1.0, representing the amount of interpolation.

Returns Vector3

The resulting vector of the interpolation.

SlideVector3
# Slide
C#
public Vector3 Slide(Vector3 normal);

Returns a new vector resulting from sliding this vector along a plane with normal n. The resulting new vector is perpendicular to n, and is equivalent to this vector minus its projection on n. See also Vector3.Project. Note: The vector n must be normalized. See also Vector3.Normalized.

Parameters
NameTypeDefault
normalVector3—
normal

The normal vector of the plane to slide on.

Returns Vector3

The slid vector.

Snapped2 overloads
# Snapped · 1/2
C#
public Vector3 Snapped(Vector3 step);

Returns a new vector with each component snapped to the nearest multiple of the corresponding component in step. This can also be used to round the components to an arbitrary number of decimals.

Parameters
NameTypeDefault
stepVector3—
step

A vector value representing the step size to snap to.

Returns Vector3

The snapped vector.

# Snapped · 2/2
C#
public Vector3 Snapped(float step);

Returns a new vector with each component snapped to the nearest multiple of the corresponding component in step. This can also be used to round the components to an arbitrary number of decimals.

Parameters
NameTypeDefault
stepfloat—
step

The step size to snap to.

Returns Vector3

The snapped vector.

ToString2 overloads
# ToString · 1/2
C#
public override string ToString();

Converts this Vector3 to a string.

Returns string

A string representation of this vector.

# ToString · 2/2
C#
public string ToString(string? format);

Converts this Vector3 to a string with the given format.

Parameters
NameTypeDefault
formatstring—
Returns string

A string representation of this vector.

op_AdditionVector3
# op_Addition
C#
public static Vector3 operator +(Vector3 left, Vector3 right);

Adds each component of the Vector3 with the components of the given Vector3.

Parameters
NameTypeDefault
leftVector3—
rightVector3—
left

The left vector.

right

The right vector.

Returns Vector3

The added vector.

op_Division2 overloads
# op_Division · 1/2
C#
public static Vector3 operator /(Vector3 vec, Vector3 divisorv);

Divides each component of the Vector3 by the components of the given Vector3.

Parameters
NameTypeDefault
vecVector3—
divisorvVector3—
vec

The dividend vector.

divisorv

The divisor vector.

Returns Vector3

The divided vector.

# op_Division · 2/2
C#
public static Vector3 operator /(Vector3 vec, float divisor);

Divides each component of the Vector3 by the given System.Single.

Parameters
NameTypeDefault
vecVector3—
divisorfloat—
vec

The dividend vector.

divisor

The divisor value.

Returns Vector3

The divided vector.

op_Equalitybool
# op_Equality
C#
public static bool operator ==(Vector3 left, Vector3 right);

Returns true if the vectors are exactly equal. Note: Due to floating-point precision errors, consider using Vector3.IsEqualApprox instead, which is more reliable.

Parameters
NameTypeDefault
leftVector3—
rightVector3—
left

The left vector.

right

The right vector.

Returns bool

Whether or not the vectors are exactly equal.

op_GreaterThanbool
# op_GreaterThan
C#
public static bool operator >(Vector3 left, Vector3 right);

Compares two Vector3 vectors by first checking if the X value of the left vector is greater than the X value of the right vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors.

Parameters
NameTypeDefault
leftVector3—
rightVector3—
left

The left vector.

right

The right vector.

Returns bool

Whether or not the left is greater than the right.

op_GreaterThanOrEqualbool
# op_GreaterThanOrEqual
C#
public static bool operator >=(Vector3 left, Vector3 right);

Compares two Vector3 vectors by first checking if the X value of the left vector is greater than or equal to the X value of the right vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors.

Parameters
NameTypeDefault
leftVector3—
rightVector3—
left

The left vector.

right

The right vector.

Returns bool

Whether or not the left is greater than or equal to the right.

op_Inequalitybool
# op_Inequality
C#
public static bool operator !=(Vector3 left, Vector3 right);

Returns true if the vectors are not equal. Note: Due to floating-point precision errors, consider using Vector3.IsEqualApprox instead, which is more reliable.

Parameters
NameTypeDefault
leftVector3—
rightVector3—
left

The left vector.

right

The right vector.

Returns bool

Whether or not the vectors are not equal.

op_LessThanbool
# op_LessThan
C#
public static bool operator <(Vector3 left, Vector3 right);

Compares two Vector3 vectors by first checking if the X value of the left vector is less than the X value of the right vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors.

Parameters
NameTypeDefault
leftVector3—
rightVector3—
left

The left vector.

right

The right vector.

Returns bool

Whether or not the left is less than the right.

op_LessThanOrEqualbool
# op_LessThanOrEqual
C#
public static bool operator <=(Vector3 left, Vector3 right);

Compares two Vector3 vectors by first checking if the X value of the left vector is less than or equal to the X value of the right vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, and then with the Z values. This operator is useful for sorting vectors.

Parameters
NameTypeDefault
leftVector3—
rightVector3—
left

The left vector.

right

The right vector.

Returns bool

Whether or not the left is less than or equal to the right.

op_Modulus2 overloads
# op_Modulus · 1/2
C#
public static Vector3 operator %(Vector3 vec, Vector3 divisorv);

Gets the remainder of each component of the Vector3 with the components of the given Vector3. This operation uses truncated division, which is often not desired as it does not work well with negative numbers. Consider using Vector3.PosMod instead if you want to handle negative numbers.

Parameters
NameTypeDefault
vecVector3—
divisorvVector3—
vec

The dividend vector.

divisorv

The divisor vector.

Returns Vector3

The remainder vector.

# op_Modulus · 2/2
C#
public static Vector3 operator %(Vector3 vec, float divisor);

Gets the remainder of each component of the Vector3 with the components of the given System.Single. This operation uses truncated division, which is often not desired as it does not work well with negative numbers. Consider using Vector3.PosMod instead if you want to handle negative numbers.

Parameters
NameTypeDefault
vecVector3—
divisorfloat—
vec

The dividend vector.

divisor

The divisor value.

Returns Vector3

The remainder vector.

op_Multiply3 overloads
# op_Multiply · 1/3
C#
public static Vector3 operator *(Vector3 left, Vector3 right);

Multiplies each component of the Vector3 by the components of the given Vector3.

Parameters
NameTypeDefault
leftVector3—
rightVector3—
left

The left vector.

right

The right vector.

Returns Vector3

The multiplied vector.

# op_Multiply · 2/3
C#
public static Vector3 operator *(Vector3 vec, float scale);

Multiplies each component of the Vector3 by the given System.Single.

Parameters
NameTypeDefault
vecVector3—
scalefloat—
vec

The vector to multiply.

scale

The scale to multiply by.

Returns Vector3

The multiplied vector.

# op_Multiply · 3/3
C#
public static Vector3 operator *(float scale, Vector3 vec);

Multiplies each component of the Vector3 by the given System.Single.

Parameters
NameTypeDefault
scalefloat—
vecVector3—
scale

The scale to multiply by.

vec

The vector to multiply.

Returns Vector3

The multiplied vector.

op_SubtractionVector3
# op_Subtraction
C#
public static Vector3 operator -(Vector3 left, Vector3 right);

Subtracts each component of the Vector3 by the components of the given Vector3.

Parameters
NameTypeDefault
leftVector3—
rightVector3—
left

The left vector.

right

The right vector.

Returns Vector3

The subtracted vector.

op_UnaryNegationVector3
# op_UnaryNegation
C#
public static Vector3 operator -(Vector3 vec);

Returns the negative value of the Vector3. This is the same as writing new Vector3(-v.X, -v.Y, -v.Z). This operation flips the direction of the vector while keeping the same magnitude. With floats, the number zero can be either positive or negative.

Parameters
NameTypeDefault
vecVector3—
vec

The vector to negate/flip.

Returns Vector3

The negated/flipped vector.

op_UnaryPlusVector3
# op_UnaryPlus
C#
public static Vector3 operator +(Vector3 vec);

Returns the same value as if the + was not there. Unary + does nothing, but sometimes it can make your code more readable.

Parameters
NameTypeDefault
vecVector3—
vec

The vector to do nothing to.

Returns Vector3

The original vector.

Fields and constants3

XField
# X
C#
public float X;

The vector's X component. Also accessible by using the index position [0].

YField
# Y
C#
public float Y;

The vector's Y component. Also accessible by using the index position [1].

ZField
# Z
C#
public float Z;

The vector's Z component. Also accessible by using the index position [2].

Vector3.Axis

ValueDescription
X = 0

Enumerated value for the X axis. Returned by Vector3.MaxAxisIndex and Vector3.MinAxisIndex.

Y = 1

Enumerated value for the Y axis. Returned by Vector3.MaxAxisIndex and Vector3.MinAxisIndex.

Z = 2

Enumerated value for the Z axis. Returned by Vector3.MaxAxisIndex and Vector3.MinAxisIndex.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.