Struct Vector3D
- Namespace
- Cobilas.GodotEngine.Utility.Numerics
- Assembly
- com.cobilas.godot.utility.dll
Represents a three-dimensional vector.
[Serializable]
public struct Vector3D : IVectorGeneric<Vector3D>, IEquatable<Vector3D>, IVector, IFormattable
- Implements
- Inherited Members
Constructors
Vector3D(Vector3D)
Starts a new instance of the object.
public Vector3D(Vector3D vector)
Parameters
vector
Vector3D
Vector3D(Vector3)
Starts a new instance of the object.
public Vector3D(Vector3 vector)
Parameters
vector
Vector3
Vector3D(float, float)
Starts a new instance of the object.
public Vector3D(float x, float y)
Parameters
Vector3D(float, float, float)
Starts a new instance of the object.
public Vector3D(float x, float y, float z)
Parameters
Fields
x
X component of the vector.
public float x
Field Value
y
Y component of the vector.
public float y
Field Value
z
Z component of the vector.
public float z
Field Value
Properties
AxisCount
Number of axles.
public readonly int AxisCount { get; }
Property Value
- int
Returns the number of axes a vector has.
Back
Shorthand for writing Vector3(0,0,-1f).
public static Vector3D Back { get; }
Property Value
Down
Shorthand for writing Vector3(0,1f,0).
public static Vector3D Down { get; }
Property Value
Forward
Shorthand for writing Vector3(0,0,1f).
public static Vector3D Forward { get; }
Property Value
this[int]
Allows you to access the axes of a vector through an index.
public float this[int index] { readonly get; set; }
Parameters
index
intThe axis index.
Property Value
- float
Sets the value of an axis by specifying its index.
Left
Shorthand for writing Vector3(-1f,0,0).
public static Vector3D Left { get; }
Property Value
Normalized
Returns the vector scaled to unit length. Equivalent to v / v.Length()
.
public readonly Vector3D Normalized { get; }
Property Value
- Vector3D
A normalized version of the vector.
One
Shorthand for writing Vector3(1,1,1).
public static Vector3D One { get; }
Property Value
Right
Shorthand for writing Vector3(1f,0,0).
public static Vector3D Right { get; }
Property Value
Up
Shorthand for writing Vector3(0,-1f,0).
public static Vector3D Up { get; }
Property Value
Zero
Shorthand for writing Vector3(0,0,0).
public static Vector3D Zero { get; }
Property Value
aspect
public readonly float aspect { get; }
Property Value
ceil
Returns a new vector with all components rounded up (towards positive infinity).
public readonly Vector3D ceil { get; }
Property Value
- Vector3D
A vector with Ceil(float) called on each component.
floor
Returns a new vector with all components rounded down (towards negative infinity).
public readonly Vector3D floor { get; }
Property Value
- Vector3D
A vector with Floor(float) called on each component.
magnitude
Returns the length (magnitude) of this vector.
public readonly float magnitude { get; }
Property Value
- float
The length of this vector.
- See Also
-
LengthSquared()
sqrMagnitude
Returns the squared length (squared magnitude) of this vector. This method runs faster than magnitude, so prefer it if you need to compare vectors or need the squared length for some formula.
public readonly float sqrMagnitude { get; }
Property Value
- float
The squared length of this vector.
Methods
Abs(in Vector3D)
Returns an absolute value of the vector.
public static Vector3D Abs(in Vector3D a)
Parameters
a
Vector3DThe vector to become absolute.
Returns
- Vector3D
Returns the vector with its absolute value axes.
Abs(bool, bool, bool)
Returns an absolute value of the vector.
public readonly Vector3D Abs(bool absX = true, bool absY = true, bool absZ = true)
Parameters
absX
boolThe X axis becomes absolute.
absY
boolThe Y axis becomes absolute.
absZ
boolThe Z axis becomes absolute.
Returns
- Vector3D
Returns the vector with its absolute value axes.
AngleTo(in Vector2D, in Vector2D)
Returns the angle in degrees between from and to.
public static float AngleTo(in Vector2D lhs, in Vector2D rhs)
Parameters
lhs
Vector2DThe vector from which the angular difference is measured.
rhs
Vector2DThe vector to which the angular difference is measured.
Returns
- float
The angle in degrees between the two vectors.
Ceil(in Vector3D)
Returns a new vector with all components rounded up (towards positive infinity).
public static Vector3D Ceil(in Vector3D a)
Parameters
a
Vector3DThe vector that will be the ceiling.
Returns
- Vector3D
A vector with Ceil(float) called on each component.
Cross(in Vector3D, in Vector3D)
Cross Product of two vectors.
public static Vector3D Cross(in Vector3D lhs, in Vector3D rhs)
Parameters
Returns
- Vector3D
Returns the cross product of vectors.
Distance(in Vector3D, in Vector3D)
Returns the distance between a and b.
public static float Distance(in Vector3D a, in Vector3D b)
Parameters
Returns
- float
The distance between two vectors.
Dot(in Vector3D, in Vector3D)
Dot Product of two vectors.
public static float Dot(in Vector3D lhs, in Vector3D rhs)
Parameters
Returns
- float
returns the result of the dot product.
Equals(Vector3D)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(Vector3D other)
Parameters
other
Vector3DAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
Floor(in Vector3D)
Returns a new vector with all components rounded down (towards negative infinity).
public static Vector3D Floor(in Vector3D a)
Parameters
a
Vector3DThe vector that will be the floor.
Returns
- Vector3D
A vector with Floor(float) called on each component.
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Magnitude(in Vector3D)
Returns the length of this vector
public static float Magnitude(in Vector3D a)
Parameters
a
Vector3DOne of the values.
Returns
- float
vector length.
Max(Vector3D, Vector3D)
Returns a vector that is made from the largest components of two vectors.
public static Vector3D Max(Vector3D lhs, Vector3D rhs)
Parameters
Returns
- Vector3D
Whichever of the two values is higher.
Min(Vector3D, Vector3D)
Returns a vector that is made from the smallest components of two vectors.
public static Vector3D Min(Vector3D lhs, Vector3D rhs)
Parameters
Returns
- Vector3D
Whichever of the two values is lower.
Neg(in Vector3D)
Inverts the values of a vector.
public static Vector3D Neg(in Vector3D a)
Parameters
a
Vector3DThe vector to be inverted.
Returns
- Vector3D
Returns the axes of an inverted vector.
Neg(bool, bool, bool)
Inverts the values of a vector.
public readonly Vector3D Neg(bool negX = true, bool negY = true, bool negZ = true)
Parameters
negX
boolThe X axis becomes inverted.
negY
boolThe Y axis becomes inverted.
negZ
boolThe Z axis becomes inverted.
Returns
- Vector3D
Returns the axes of an inverted vector.
Normalize(in Vector3D)
Makes this vector have a magnitude of 1.
public static Vector3D Normalize(in Vector3D a)
Parameters
a
Vector3DThe vector to be normalized.
Returns
- Vector3D
Returns the already normalized vector.
Round()
Returns this vector with all components rounded to the nearest integer, with halfway cases rounded towards the nearest multiple of two.
public readonly Vector3D Round()
Returns
- Vector3D
The rounded vector.
Round(in Vector3D)
Returns this vector with all components rounded to the nearest integer, with halfway cases rounded towards the nearest multiple of two.
public static Vector3D Round(in Vector3D a)
Parameters
a
Vector3Dthe vector to be rounded
Returns
- Vector3D
The rounded vector.
SqrMagnitude(in Vector3D)
Returns the squared length of this vector
public static float SqrMagnitude(in Vector3D a)
Parameters
a
Vector3DOne of the values.
Returns
- float
square length of the vector.
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
Returns
- string
The fully qualified type name.
ToString(string)
Formats the value of the current instance using the specified format.
public readonly string ToString(string format)
Parameters
format
stringThe format to use.-or- A null reference (
Nothing
in Visual Basic) to use the default format defined for the type of the IFormattable implementation.
Returns
- string
The value of the current instance in the specified format.
ToString(string, IFormatProvider)
Formats the value of the current instance using the specified format.
public readonly string ToString(string format, IFormatProvider formatProvider)
Parameters
format
stringThe format to use.-or- A null reference (
Nothing
in Visual Basic) to use the default format defined for the type of the IFormattable implementation.formatProvider
IFormatProviderThe provider to use to format the value.-or- A null reference (
Nothing
in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
Operators
operator +(Vector3D, Vector3D)
public static Vector3D operator +(Vector3D a, Vector3D b)
Parameters
Returns
- Vector3D
The result of the addition.
operator +(Vector3D, Vector3)
Addition operation between two values.(Vector3D + Godot.Vector3)
public static Vector3D operator +(Vector3D a, Vector3 b)
Parameters
a
Vector3DFirst module.
b
Vector3Second module.
Returns
- Vector3D
The result of the addition.
operator +(Vector3, Vector3D)
Addition operation between two values.(Godot.Vector3 + Vector3D)
public static Vector3D operator +(Vector3 a, Vector3D b)
Parameters
a
Vector3First module.
b
Vector3DSecond module.
Returns
- Vector3D
The result of the addition.
operator /(Vector3D, Vector3D)
public static Vector3D operator /(Vector3D a, Vector3D b)
Parameters
Returns
- Vector3D
The result of the division.
operator /(Vector3D, Vector3)
Division operation between two values.(Vector3D / Godot.Vector3)
public static Vector3D operator /(Vector3D a, Vector3 b)
Parameters
a
Vector3DFirst module.
b
Vector3Second module.
Returns
- Vector3D
The result of the division.
operator /(Vector3D, float)
public static Vector3D operator /(Vector3D a, float b)
Parameters
Returns
- Vector3D
The result of the division.
operator /(Vector3, Vector3D)
Division operation between two values.(Godot.Vector3 / Vector3D)
public static Vector3D operator /(Vector3 a, Vector3D b)
Parameters
a
Vector3First module.
b
Vector3DSecond module.
Returns
- Vector3D
The result of the division.
operator ==(in Vector3D, in Vector3D)
Indicates whether this instance is equal to another instance of the same type.
public static bool operator ==(in Vector3D lhs, in Vector3D rhs)
Parameters
Returns
- bool
Returns the result of the comparison.
implicit operator Vector2D(Vector3D)
public static implicit operator Vector2D(Vector3D v)
Parameters
v
Vector3DObject to be converted.
Returns
implicit operator Vector4D(Vector3D)
public static implicit operator Vector4D(Vector3D v)
Parameters
v
Vector3DObject to be converted.
Returns
implicit operator Vector2(Vector3D)
Implicit conversion operator.(Vector3D to Godot.Vector2)
public static implicit operator Vector2(Vector3D v)
Parameters
v
Vector3DObject to be converted.
Returns
- Vector2
implicit operator Vector3(Vector3D)
Implicit conversion operator.(Vector3D to Godot.Vector3)
public static implicit operator Vector3(Vector3D v)
Parameters
v
Vector3DObject to be converted.
Returns
- Vector3
implicit operator Vector3D(Vector2)
Implicit conversion operator.(Godot.Vector2 to Vector3D)
public static implicit operator Vector3D(Vector2 v)
Parameters
v
Vector2Object to be converted.
Returns
implicit operator Vector3D(Vector3)
Implicit conversion operator.(Godot.Vector3 to Vector3D)
public static implicit operator Vector3D(Vector3 v)
Parameters
v
Vector3Object to be converted.
Returns
operator !=(in Vector3D, in Vector3D)
Indicates whether this instance is different from another instance of the same type.
public static bool operator !=(in Vector3D lhs, in Vector3D rhs)
Parameters
Returns
- bool
Returns the result of the comparison.
operator *(Vector3D, Vector3D)
public static Vector3D operator *(Vector3D a, Vector3D b)
Parameters
Returns
- Vector3D
The result of the multiplication.
operator *(Vector3D, Vector3)
Multiplication operation between two values.(Vector3D * Godot.Vector3)
public static Vector3D operator *(Vector3D a, Vector3 b)
Parameters
a
Vector3DFirst module.
b
Vector3Second module.
Returns
- Vector3D
The result of the multiplication.
operator *(Vector3D, float)
public static Vector3D operator *(Vector3D a, float b)
Parameters
Returns
- Vector3D
The result of the multiplication.
operator *(Vector3, Vector3D)
Multiplication operation between two values.(Godot.Vector3 * Vector3D)
public static Vector3D operator *(Vector3 a, Vector3D b)
Parameters
a
Vector3First module.
b
Vector3DSecond module.
Returns
- Vector3D
The result of the multiplication.
operator -(Vector3D, Vector3D)
public static Vector3D operator -(Vector3D a, Vector3D b)
Parameters
Returns
- Vector3D
The result of the subtraction.
operator -(Vector3D, Vector3)
Subtraction operation between two values.(Vector3D - Godot.Vector3)
public static Vector3D operator -(Vector3D a, Vector3 b)
Parameters
a
Vector3DFirst module.
b
Vector3Second module.
Returns
- Vector3D
The result of the subtraction.
operator -(Vector3, Vector3D)
Subtraction operation between two values.(Godot.Vector3 - Vector3D)
public static Vector3D operator -(Vector3 a, Vector3D b)
Parameters
a
Vector3First module.
b
Vector3DSecond module.
Returns
- Vector3D
The result of the subtraction.
operator -(Vector3D)
The operator allows us to reverse the value.
public static Vector3D operator -(Vector3D a)
Parameters
a
Vector3DOr value that will be invested.
Returns
- Vector3D
Returns the result of the inversion.