Vector3
A three-component value for 3D coordinates and calculations.
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.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
Properties16
BackProperty
public static Vector3 Back { get; }Back unit vector. Represents the local direction of back, and the global direction of south.
DownProperty
public static Vector3 Down { get; }Down unit vector.
ForwardProperty
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
public static Vector3 Inf { get; }Infinity vector, a vector with all components set to @C#.INF.
ItemProperty
public float this[int index] { get; set; }Access vector components using their index.
LeftProperty
public static Vector3 Left { get; }Left unit vector. Represents the local direction of left, and the global direction of west.
ModelBottomProperty
public static Vector3 ModelBottom { get; }Unit vector pointing towards the bottom side (down) of imported 3D assets.
ModelFrontProperty
public static Vector3 ModelFront { get; }Unit vector pointing towards the front side (facing forward) of imported 3D assets.
ModelLeftProperty
public static Vector3 ModelLeft { get; }Unit vector pointing towards the left side of imported 3D assets.
ModelRearProperty
public static Vector3 ModelRear { get; }Unit vector pointing towards the rear side (back) of imported 3D assets.
ModelRightProperty
public static Vector3 ModelRight { get; }Unit vector pointing towards the right side of imported 3D assets.
ModelTopProperty
public static Vector3 ModelTop { get; }Unit vector pointing towards the top side (up) of imported 3D assets.
OneProperty
public static Vector3 One { get; }One vector, a vector with all components set to 1.
RightProperty
public static Vector3 Right { get; }Right unit vector. Represents the local direction of right, and the global direction of east.
UpProperty
public static Vector3 Up { get; }Up unit vector.
ZeroProperty
public static Vector3 Zero { get; }Zero vector, a vector with all components set to 0.
Methods71
AbsVector3
AngleTofloat
public float AngleTo(Vector3 to);Returns the unsigned minimum angle to the given vector, in radians.
| Name | Type | Default |
|---|---|---|
to | Vector3 | — |
toThe other vector to compare this vector to.
floatThe unsigned angle between the two vectors, in radians.
BezierDerivativeVector3
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.
| Name | Type | Default |
|---|---|---|
control1 | Vector3 | — |
control2 | Vector3 | — |
end | Vector3 | — |
t | float | — |
control1Control point that defines the bezier curve.
control2Control point that defines the bezier curve.
endThe destination value for the interpolation.
tA value on the range of 0.0 to 1.0, representing the amount of interpolation.
Vector3The resulting value of the interpolation.
BezierInterpolateVector3
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.
| Name | Type | Default |
|---|---|---|
control1 | Vector3 | — |
control2 | Vector3 | — |
end | Vector3 | — |
t | float | — |
control1Control point that defines the bezier curve.
control2Control point that defines the bezier curve.
endThe destination vector.
tA value on the range of 0.0 to 1.0, representing the amount of interpolation.
Vector3The interpolated vector.
BounceVector3
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()`.
| Name | Type | Default |
|---|---|---|
normal | Vector3 | — |
normalThe normal vector defining the plane to bounce off. Must be normalized.
Vector3The bounced vector.
CeilVector3
public Vector3 Ceil();Returns a new vector with all components rounded up (towards positive infinity).
Clamp2 overloads
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.
| Name | Type | Default |
|---|---|---|
min | Vector3 | — |
max | Vector3 | — |
minThe vector with minimum allowed values.
maxThe vector with maximum allowed values.
Vector3The vector with all components clamped.
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.
| Name | Type | Default |
|---|---|---|
min | float | — |
max | float | — |
minThe minimum allowed value.
maxThe maximum allowed value.
Vector3The vector with all components clamped.
CrossVector3
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.
| Name | Type | Default |
|---|---|---|
with | Vector3 | — |
withThe other vector.
Vector3The cross product vector.
CubicInterpolateVector3
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.
| Name | Type | Default |
|---|---|---|
b | Vector3 | — |
preA | Vector3 | — |
postB | Vector3 | — |
weight | float | — |
bThe destination vector.
preAA vector before this vector.
postBA vector after b.
weightA value on the range of 0.0 to 1.0, representing the amount of interpolation.
Vector3The interpolated vector.
CubicInterpolateInTimeVector3
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.
| Name | Type | Default |
|---|---|---|
b | Vector3 | — |
preA | Vector3 | — |
postB | Vector3 | — |
weight | float | — |
t | float | — |
preAT | float | — |
postBT | float | — |
bThe destination vector.
preAA vector before this vector.
postBA vector after b.
weightA value on the range of 0.0 to 1.0, representing the amount of interpolation.
Vector3The interpolated vector.
Deconstructvoid
public void Deconstruct(out float x, out float y, out float z);Helper method for deconstruction into a tuple.
| Name | Type | Default |
|---|---|---|
x | float | — |
y | float | — |
z | float | — |
DirectionToVector3
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.
| Name | Type | Default |
|---|---|---|
to | Vector3 | — |
toThe other vector to point towards.
Vector3The direction from this vector to to.
DistanceSquaredTofloat
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.
| Name | Type | Default |
|---|---|---|
to | Vector3 | — |
toThe other vector to use.
floatThe squared distance between the two vectors.
DistanceTofloat
public float DistanceTo(Vector3 to);Returns the Euclidean distance between this vector and to.
| Name | Type | Default |
|---|---|---|
to | Vector3 | — |
toThe other vector to use.
floatThe distance between the two vectors.
Dotfloat
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).
| Name | Type | Default |
|---|---|---|
with | Vector3 | — |
withThe other vector to use.
floatThe dot product of the two vectors.
Equals2 overloads
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.
| Name | Type | Default |
|---|---|---|
other | Vector3 | — |
otherThe other vector.
boolWhether or not the vectors are exactly equal.
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.
| Name | Type | Default |
|---|---|---|
obj | object | — |
objThe object to compare with.
boolWhether or not the vector and the object are equal.
FloorVector3
public Vector3 Floor();Returns a new vector with all components rounded down (towards negative infinity).
GetHashCodeint
public override int GetHashCode();Serves as the hash function for Vector3.
intA hash code for this vector.
InverseVector3
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).
Vector3The inverse of this vector.
IsEqualApproxbool
public bool IsEqualApprox(Vector3 other);Returns true if this vector and to are approximately equal, by running @GlobalScope.is_equal_approx on each component.
| Name | Type | Default |
|---|---|---|
other | Vector3 | — |
otherThe other vector to compare.
boolWhether or not the vectors are approximately equal.
IsFinitebool
public bool IsFinite();Returns true if this vector is finite, by calling @GlobalScope.is_finite on each component.
boolWhether this vector is finite or not.
IsNormalizedbool
public bool IsNormalized();Returns true if the vector is normalized, i.e. its length is approximately equal to 1.
boolA bool indicating whether or not the vector is normalized.
IsZeroApproxbool
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.
boolWhether or not the vector is approximately zero.
Lengthfloat
public float Length();Returns the length (magnitude) of this vector.
floatThe length of this vector.
LengthSquaredfloat
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.
floatThe squared length of this vector.
LerpVector3
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.
| Name | Type | Default |
|---|---|---|
to | Vector3 | — |
weight | float | — |
toThe destination vector for interpolation.
weightA value on the range of 0.0 to 1.0, representing the amount of interpolation.
Vector3The resulting vector of the interpolation.
LimitLengthVector3
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.
| Name | Type | Default |
|---|---|---|
length | float | 1f |
lengthThe length to limit to.
Vector3The vector with its length limited.
Max2 overloads
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)).
| Name | Type | Default |
|---|---|---|
with | Vector3 | — |
withThe other vector to use.
Vector3The resulting maximum vector.
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)).
| Name | Type | Default |
|---|---|---|
with | float | — |
withThe other value to use.
Vector3The resulting maximum vector.
MaxAxisIndexVector3.Axis
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.
Vector3.AxisThe index of the highest axis.
Min2 overloads
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)).
| Name | Type | Default |
|---|---|---|
with | Vector3 | — |
withThe other vector to use.
Vector3The resulting minimum vector.
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)).
| Name | Type | Default |
|---|---|---|
with | float | — |
withThe other value to use.
Vector3The resulting minimum vector.
MinAxisIndexVector3.Axis
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.
Vector3.AxisThe index of the lowest axis.
MoveTowardVector3
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.
| Name | Type | Default |
|---|---|---|
to | Vector3 | — |
delta | float | — |
toThe vector to move towards.
deltaThe amount to move towards by.
Vector3The resulting vector.
NormalizedVector3
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.
Vector3A normalized version of the vector.
OctahedronDecodeVector3
public static Vector3 OctahedronDecode(Vector2 oct);Returns the Vector3 from an octahedral-compressed form created using Vector3.OctahedronEncode (stored as a Vector2).
| Name | Type | Default |
|---|---|---|
oct | Vector2 | — |
octEncoded Vector2
Vector3The decoded normalized Vector3.
OctahedronEncodeVector2
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.
Vector2The encoded Vector2.
OuterBasis
PosMod2 overloads
public Vector3 PosMod(Vector3 modv);Returns a vector composed of the @GlobalScope.fposmod of this vector's components and mod.
| Name | Type | Default |
|---|---|---|
modv | Vector3 | — |
modvA vector representing the divisors of the operation.
public Vector3 PosMod(float mod);Returns a vector composed of the @GlobalScope.fposmod of this vector's components and mod.
| Name | Type | Default |
|---|---|---|
mod | float | — |
modA value representing the divisor of the operation.
ProjectVector3
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.
| Name | Type | Default |
|---|---|---|
onNormal | Vector3 | — |
onNormalThe vector to project onto.
Vector3The projected vector.
ReflectVector3
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()`.
| Name | Type | Default |
|---|---|---|
normal | Vector3 | — |
normalThe normal vector defining the plane to reflect from. Must be normalized.
Vector3The reflected vector.
RotatedVector3
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.
| Name | Type | Default |
|---|---|---|
axis | Vector3 | — |
angle | float | — |
axisThe vector to rotate around. Must be normalized.
angleThe angle to rotate by, in radians.
Vector3The rotated vector.
RoundVector3
public Vector3 Round();Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
Vector3The rounded vector.
SignVector3
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.
Vector3A vector with all components as either 1, -1, or 0.
SignedAngleTofloat
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.
| Name | Type | Default |
|---|---|---|
to | Vector3 | — |
axis | Vector3 | — |
toThe other vector to compare this vector to.
axisThe reference axis to use for the angle sign.
floatThe signed angle between the two vectors, in radians.
SlerpVector3
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.
| Name | Type | Default |
|---|---|---|
to | Vector3 | — |
weight | float | — |
toThe destination vector for interpolation.
weightA value on the range of 0.0 to 1.0, representing the amount of interpolation.
Vector3The resulting vector of the interpolation.
SlideVector3
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.
| Name | Type | Default |
|---|---|---|
normal | Vector3 | — |
normalThe normal vector of the plane to slide on.
Vector3The slid vector.
Snapped2 overloads
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.
| Name | Type | Default |
|---|---|---|
step | Vector3 | — |
stepA vector value representing the step size to snap to.
Vector3The snapped vector.
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.
| Name | Type | Default |
|---|---|---|
step | float | — |
stepThe step size to snap to.
Vector3The snapped vector.
ToString2 overloads
public override string ToString();Converts this Vector3 to a string.
stringA string representation of this vector.
public string ToString(string? format);Converts this Vector3 to a string with the given format.
| Name | Type | Default |
|---|---|---|
format | string | — |
stringA string representation of this vector.
op_AdditionVector3
public static Vector3 operator +(Vector3 left, Vector3 right);Adds each component of the Vector3
with the components of the given Vector3.
| Name | Type | Default |
|---|---|---|
left | Vector3 | — |
right | Vector3 | — |
leftThe left vector.
rightThe right vector.
Vector3The added vector.
op_Division2 overloads
public static Vector3 operator /(Vector3 vec, Vector3 divisorv);Divides each component of the Vector3
by the components of the given Vector3.
| Name | Type | Default |
|---|---|---|
vec | Vector3 | — |
divisorv | Vector3 | — |
vecThe dividend vector.
divisorvThe divisor vector.
Vector3The divided vector.
public static Vector3 operator /(Vector3 vec, float divisor);Divides each component of the Vector3
by the given System.Single.
| Name | Type | Default |
|---|---|---|
vec | Vector3 | — |
divisor | float | — |
vecThe dividend vector.
divisorThe divisor value.
Vector3The divided vector.
op_Equalitybool
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.
| Name | Type | Default |
|---|---|---|
left | Vector3 | — |
right | Vector3 | — |
leftThe left vector.
rightThe right vector.
boolWhether or not the vectors are exactly equal.
op_GreaterThanbool
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.
| Name | Type | Default |
|---|---|---|
left | Vector3 | — |
right | Vector3 | — |
leftThe left vector.
rightThe right vector.
boolWhether or not the left is greater than the right.
op_GreaterThanOrEqualbool
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.
| Name | Type | Default |
|---|---|---|
left | Vector3 | — |
right | Vector3 | — |
leftThe left vector.
rightThe right vector.
boolWhether or not the left is greater than or equal to the right.
op_Inequalitybool
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.
| Name | Type | Default |
|---|---|---|
left | Vector3 | — |
right | Vector3 | — |
leftThe left vector.
rightThe right vector.
boolWhether or not the vectors are not equal.
op_LessThanbool
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.
| Name | Type | Default |
|---|---|---|
left | Vector3 | — |
right | Vector3 | — |
leftThe left vector.
rightThe right vector.
boolWhether or not the left is less than the right.
op_LessThanOrEqualbool
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.
| Name | Type | Default |
|---|---|---|
left | Vector3 | — |
right | Vector3 | — |
leftThe left vector.
rightThe right vector.
boolWhether or not the left is less than or equal to the right.
op_Modulus2 overloads
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.
| Name | Type | Default |
|---|---|---|
vec | Vector3 | — |
divisorv | Vector3 | — |
vecThe dividend vector.
divisorvThe divisor vector.
Vector3The remainder vector.
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.
| Name | Type | Default |
|---|---|---|
vec | Vector3 | — |
divisor | float | — |
vecThe dividend vector.
divisorThe divisor value.
Vector3The remainder vector.
op_Multiply3 overloads
public static Vector3 operator *(Vector3 left, Vector3 right);Multiplies each component of the Vector3
by the components of the given Vector3.
| Name | Type | Default |
|---|---|---|
left | Vector3 | — |
right | Vector3 | — |
leftThe left vector.
rightThe right vector.
Vector3The multiplied vector.
public static Vector3 operator *(Vector3 vec, float scale);Multiplies each component of the Vector3
by the given System.Single.
| Name | Type | Default |
|---|---|---|
vec | Vector3 | — |
scale | float | — |
vecThe vector to multiply.
scaleThe scale to multiply by.
Vector3The multiplied vector.
public static Vector3 operator *(float scale, Vector3 vec);Multiplies each component of the Vector3
by the given System.Single.
| Name | Type | Default |
|---|---|---|
scale | float | — |
vec | Vector3 | — |
scaleThe scale to multiply by.
vecThe vector to multiply.
Vector3The multiplied vector.
op_SubtractionVector3
public static Vector3 operator -(Vector3 left, Vector3 right);Subtracts each component of the Vector3
by the components of the given Vector3.
| Name | Type | Default |
|---|---|---|
left | Vector3 | — |
right | Vector3 | — |
leftThe left vector.
rightThe right vector.
Vector3The subtracted vector.
op_UnaryNegationVector3
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.
| Name | Type | Default |
|---|---|---|
vec | Vector3 | — |
vecThe vector to negate/flip.
Vector3The negated/flipped vector.
op_UnaryPlusVector3
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.
| Name | Type | Default |
|---|---|---|
vec | Vector3 | — |
vecThe vector to do nothing to.
Vector3The original vector.
Fields and constants3
XField
public float X;The vector's X component. Also accessible by using the index position [0].
YField
public float Y;The vector's Y component. Also accessible by using the index position [1].
ZField
public float Z;The vector's Z component. Also accessible by using the index position [2].
Vector3.Axis
| Value | Description |
|---|---|
X = 0 | Enumerated value for the X axis. Returned by |
Y = 1 | Enumerated value for the Y axis. Returned by |
Z = 2 | Enumerated value for the Z axis. Returned by |