Vector3
La référence est en anglais : elle est générée à partir des commentaires du code, écrits en anglais.
public struct Vector3 : IEquatable<Vector3>, IFormattableNamespace NodeWorld.Flux.
A point or a direction in 3D, as Unity's Vector3: x right, y up, z forward.
Constants
kEpsilon
public const float kEpsilon = 0.00001fThe tolerance of == and of Normalize (0.00001).
kEpsilonNormalSqrt
public const float kEpsilonNormalSqrt = 1e-15fWhen the product of the two lengths is below this, Angle gives 0 (1e-15).
Fields
x
public float xThe x component.
y
public float yThe y component.
z
public float zThe z component.
Constructors
Vector3
public Vector3(float x, float y, float z)A vector of these components.
public Vector3(float x, float y)A vector of x and y, z at 0.
Properties
this[]
public float this[int index] { get; set; }x, y, z by index 0 to 2.
zero
public static Vector3 zero { get; }(0, 0, 0).
one
public static Vector3 one { get; }(1, 1, 1).
up
public static Vector3 up { get; }(0, 1, 0): up.
down
public static Vector3 down { get; }(0, -1, 0): down.
left
public static Vector3 left { get; }(-1, 0, 0): left.
right
public static Vector3 right { get; }(1, 0, 0): right.
forward
public static Vector3 forward { get; }(0, 0, 1): forward.
back
public static Vector3 back { get; }(0, 0, -1): back.
positiveInfinity
public static Vector3 positiveInfinity { get; }Every component at positive infinity.
negativeInfinity
public static Vector3 negativeInfinity { get; }Every component at negative infinity.
magnitude
public float magnitude { get; }Length of the vector.
sqrMagnitude
public float sqrMagnitude { get; }Squared length: quicker than magnitude, to compare lengths.
normalized
public Vector3 normalized { get; }The vector at length 1 (zero when it is too short).
Methods
Normalize
public void Normalize()Brings the vector to length 1 (zero when it is too short).
public static Vector3 Normalize(Vector3 value)value at length 1 (zero when its length is under kEpsilon).
Set
public void Set(float newX, float newY, float newZ)Sets the three components.
Scale
public void Scale(Vector3 scale)Multiplies each component by the one of scale.
public static Vector3 Scale(Vector3 a, Vector3 b)a and b multiplied component by component.
Dot
public static float Dot(Vector3 lhs, Vector3 rhs)Dot product.
Cross
public static Vector3 Cross(Vector3 lhs, Vector3 rhs)Cross product: a vector at right angles to both.
Distance
public static float Distance(Vector3 a, Vector3 b)Distance between two points.
SqrMagnitude
public static float SqrMagnitude(Vector3 vector)Squared length of vector.
Magnitude
public static float Magnitude(Vector3 vector)Length of vector.
Lerp
public static Vector3 Lerp(Vector3 a, Vector3 b, float t)From a (t = 0) to b (t = 1); t is kept between 0 and 1.
LerpUnclamped
public static Vector3 LerpUnclamped(Vector3 a, Vector3 b, float t)From a (t = 0) to b (t = 1); t is not limited.
MoveTowards
public static Vector3 MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta)current moved towards target by maxDistanceDelta at most.
RotateTowards
public static Vector3 RotateTowards(Vector3 current, Vector3 target, float maxRadiansDelta, float maxMagnitudeDelta)Turns "current" towards "target" by at most maxRadiansDelta, and moves its length towards target's by at most maxMagnitudeDelta (as Unity).
Angle
public static float Angle(Vector3 from, Vector3 to)Angle in degrees between two vectors (0 to 180).
SignedAngle
public static float SignedAngle(Vector3 from, Vector3 to, Vector3 axis)Angle in degrees from "from" to "to", signed by the rotation around axis.
Project
public static Vector3 Project(Vector3 vector, Vector3 onNormal)vector projected on the line of onNormal (zero for a zero onNormal).
ProjectOnPlane
public static Vector3 ProjectOnPlane(Vector3 vector, Vector3 planeNormal)vector projected on the plane whose normal is planeNormal.
Reflect
public static Vector3 Reflect(Vector3 inDirection, Vector3 inNormal)inDirection reflected off the plane whose normal is inNormal (of length 1).
ClampMagnitude
public static Vector3 ClampMagnitude(Vector3 vector, float maxLength)vector shortened to maxLength when it is longer.
Min
public static Vector3 Min(Vector3 a, Vector3 b)The smaller component of a and b, on each axis.
Max
public static Vector3 Max(Vector3 a, Vector3 b)The larger component of a and b, on each axis.
Equals
public bool Equals(Vector3 other)The components are exactly equal.
public override bool Equals(object other)other is a Vector3 with exactly the same components.
GetHashCode
public override int GetHashCode()A hash of the components.
ToString
public override string ToString()"(x, y, z)" with 2 decimals.
public string ToString(string format)The same text with the numbers in format.
public string ToString(string format, IFormatProvider formatProvider)The same text with the numbers in format (F2 when empty) and formatProvider (the invariant culture when null).
Operators
operator +
public static Vector3 operator +(Vector3 a, Vector3 b)Sum.
operator -
public static Vector3 operator -(Vector3 a, Vector3 b)Difference.
public static Vector3 operator -(Vector3 a)The opposite vector.
operator *
public static Vector3 operator *(Vector3 a, float d)Each component times d.
public static Vector3 operator *(float d, Vector3 a)Each component times d.
operator /
public static Vector3 operator /(Vector3 a, float d)Each component divided by d.
operator ==
public static bool operator ==(Vector3 lhs, Vector3 rhs)Approximately equal: the squared distance is below 1e-10.
operator !=
public static bool operator !=(Vector3 lhs, Vector3 rhs)Not approximately equal (see ==).
implicit operator Vector2
public static implicit operator Vector2(Vector3 v)x and y of the vector.
implicit operator Vector3
public static implicit operator Vector3(Vector2 v)x and y of the vector, z at 0.
