3-dimensional vector class. More...
#include <Vector3.h>
Public Member Functions | |
AZ_TYPE_INFO (Vector3, "{8379EB7D-01FA-4538-B64B-A6543B4BE73D}") | |
Vector3 ()=default | |
Default constructor, components are uninitialized. | |
Vector3 (const Vector3 &v)=default | |
Vector3 (float x) | |
Constructs vector with all components set to the same specified value. | |
Vector3 (float x, float y, float z) | |
Vector3 (const Vector2 &source) | |
Sets x,y components from a Vector2, sets z to 0.0. | |
Vector3 (const Vector2 &source, float z) | |
Sets x,y components from a Vector2, specify z separately. | |
Vector3 (const Vector4 &source) | |
Sets x,y,z components from a Vector4. | |
Vector3 (Simd::Vec3::FloatArgType value) | |
For internal use only, arrangement of values in SIMD type is not guaranteed. | |
void | StoreToFloat3 (float *values) const |
void | StoreToFloat4 (float *values) const |
float | GetX () const |
float | GetY () const |
float | GetZ () const |
void | SetX (float x) |
void | SetY (float y) |
void | SetZ (float z) |
float | GetElement (int32_t index) const |
We recommend using GetX,Y,Z. GetElement can be slower. | |
void | SetElement (int32_t index, float v) |
We recommend using SetX,Y,Z. SetElement can be slower. | |
void | Set (float x) |
Sets all components to the same specified value. | |
void | Set (float x, float y, float z) |
void | Set (const float values[]) |
Sets components from an array of 3 floats in xyz order. | |
float | operator() (int32_t index) const |
Indexed access using operator(), just for convenience. | |
float | GetLengthSq () const |
Returns squared length of the vector. | |
float | GetLength () const |
Returns length of the vector, full accuracy. | |
float | GetLengthEstimate () const |
Returns length of the vector, fast but low accuracy, uses raw estimate instructions. | |
float | GetLengthReciprocal () const |
Returns 1/length, full accuracy. | |
float | GetLengthReciprocalEstimate () const |
Returns 1/length of the vector, fast but low accuracy, uses raw estimate instructions. | |
Vector3 | GetNormalized () const |
Returns normalized vector, full accuracy. | |
Vector3 | GetNormalizedEstimate () const |
Returns normalized vector, fast but low accuracy, uses raw estimate instructions. | |
void | Normalize () |
Normalizes the vector in-place, full accuracy. | |
void | NormalizeEstimate () |
Normalizes the vector in-place, fast but low accuracy, uses raw estimate instructions. | |
bool | IsNormalized (float tolerance=Constants::Tolerance) const |
void | SetLength (float length) |
Scales the vector to have the specified length, full accuracy. | |
void | SetLengthEstimate (float length) |
Scales the vector to have the specified length, fast but low accuracy, uses raw estimate instructions. | |
float | GetDistanceSq (const Vector3 &v) const |
Returns squared distance to another Vector3. | |
Vector3 | Lerp (const Vector3 &dest, float t) const |
Vector3 | Slerp (const Vector3 &dest, float t) const |
Vector3 | Nlerp (const Vector3 &dest, float t) const |
float | Dot (const Vector3 &rhs) const |
Dot product of two vectors. | |
Vector3 | Cross (const Vector3 &rhs) const |
Cross product of two vectors. | |
bool | IsClose (const Vector3 &v, float tolerance=Constants::Tolerance) const |
Checks the vector is equal to another within a floating point tolerance. | |
bool | IsZero (float tolerance=Constants::FloatEpsilon) const |
bool | operator== (const Vector3 &rhs) const |
bool | operator!= (const Vector3 &rhs) const |
float | GetMaxElement () const |
float | GetMinElement () const |
Vector3 | operator- () const |
Vector3 | operator+ (const Vector3 &rhs) const |
Vector3 | operator- (const Vector3 &rhs) const |
Vector3 | operator* (const Vector3 &rhs) const |
Vector3 | operator/ (const Vector3 &rhs) const |
Vector3 | operator* (float multiplier) const |
Vector3 | operator/ (float divisor) const |
Vector3 & | operator+= (const Vector3 &rhs) |
Vector3 & | operator-= (const Vector3 &rhs) |
Vector3 & | operator*= (const Vector3 &rhs) |
Vector3 & | operator/= (const Vector3 &rhs) |
Vector3 & | operator*= (float multiplier) |
Vector3 & | operator/= (float divisor) |
Vector3 | GetSin () const |
Gets the sine of each component. | |
Vector3 | GetCos () const |
Gets the cosine of each component. | |
void | GetSinCos (Vector3 &sin, Vector3 &cos) const |
Gets the sine and cosine of each component, quicker than calling GetSin and GetCos separately. | |
Vector3 | GetAcos () const |
Gets the arccosine of each component. | |
Vector3 | GetAtan () const |
Gets the arctangent of each component. | |
Vector3 | GetAngleMod () const |
Wraps the angle in each component into the [-pi,pi] range. | |
float | Angle (const Vector3 &v) const |
float | AngleDeg (const Vector3 &v) const |
float | AngleSafe (const Vector3 &v) const |
Calculates the closest angle(radians) towards the given vector with in the [0, pi] range. | |
float | AngleSafeDeg (const Vector3 &v) const |
Calculates the closest angle(degrees) towards the given vector with in the [0, 180] range. | |
Vector3 | GetAbs () const |
Takes the absolute value of each component of the vector. | |
Vector3 | GetReciprocal () const |
Returns the reciprocal of each component of the vector, full accuracy. | |
Vector3 | GetReciprocalEstimate () const |
Returns the reciprocal of each component of the vector, fast but low accuracy, uses raw estimate instructions. | |
void | BuildTangentBasis (Vector3 &tangent, Vector3 &bitangent) const |
Builds a tangent basis with this vector as the normal. | |
Vector3 | GetMadd (const Vector3 &mul, const Vector3 &add) |
Perform multiply-add operator, returns this * mul + add. | |
void | Madd (const Vector3 &mul, const Vector3 &add) |
Perform multiply-add operator (this = this * mul + add). | |
bool | IsPerpendicular (const Vector3 &v, float tolerance=Constants::Tolerance) const |
Vector3 | GetOrthogonalVector () const |
Returns an (unnormalized) arbitrary vector which is orthogonal to this vector. | |
void | Project (const Vector3 &rhs) |
Project vector onto another. P = (a.Dot(b) / b.Dot(b)) * b. | |
void | ProjectOnNormal (const Vector3 &normal) |
Project vector onto a normal (faster function). P = (v.Dot(Normal) * normal) | |
Vector3 | GetProjected (const Vector3 &rhs) const |
Project this vector onto another and return the resulting projection. P = (a.Dot(b) / b.Dot(b)) * b. | |
Vector3 | GetProjectedOnNormal (const Vector3 &normal) |
Project this vector onto a normal and return the resulting projection. P = v - (v.Dot(Normal) * normal) | |
bool | IsFinite () const |
Returns true if the vector contains no nan or inf values, false if at least one element is not finite. | |
Simd::Vec3::FloatType | GetSimdValue () const |
Returns the underlying SIMD vector. | |
void | SetSimdValue (Simd::Vec3::FloatArgType value) |
Directly sets the underlying SIMD vector. | |
float | NormalizeWithLength () |
float | NormalizeWithLengthEstimate () |
Vector3 | GetNormalizedSafe (float tolerance=Constants::Tolerance) const |
Vector3 | GetNormalizedSafeEstimate (float tolerance=Constants::Tolerance) const |
void | NormalizeSafe (float tolerance=Constants::Tolerance) |
void | NormalizeSafeEstimate (float tolerance=Constants::Tolerance) |
float | NormalizeSafeWithLength (float tolerance=Constants::Tolerance) |
float | NormalizeSafeWithLengthEstimate (float tolerance=Constants::Tolerance) |
float | GetDistance (const Vector3 &v) const |
float | GetDistanceEstimate (const Vector3 &v) const |
Vector3 | CrossXAxis () const |
Vector3 | CrossYAxis () const |
Vector3 | CrossZAxis () const |
Vector3 | XAxisCross () const |
Vector3 | YAxisCross () const |
Vector3 | ZAxisCross () const |
bool | IsLessThan (const Vector3 &rhs) const |
bool | IsLessEqualThan (const Vector3 &rhs) const |
bool | IsGreaterThan (const Vector3 &rhs) const |
bool | IsGreaterEqualThan (const Vector3 &rhs) const |
Vector3 | GetFloor () const |
Vector3 | GetCeil () const |
Vector3 | GetRound () const |
Vector3 | GetMin (const Vector3 &v) const |
Vector3 | GetMax (const Vector3 &v) const |
Vector3 | GetClamp (const Vector3 &min, const Vector3 &max) const |
Static Public Member Functions | |
static void | Reflect (ReflectContext *context) |
static Vector3 | CreateZero () |
Creates a vector with all components set to zero, more efficient than calling Vector3(0.0f). | |
static Vector3 | CreateOne () |
Creates a vector with all components set to one. | |
static Vector3 | CreateAxisX (float length=1.0f) |
static Vector3 | CreateAxisY (float length=1.0f) |
static Vector3 | CreateAxisZ (float length=1.0f) |
static Vector3 | CreateFromFloat3 (const float *values) |
Sets components from an array of 3 floats, stored in xyz order. | |
static Vector3 | CreateSelectCmpEqual (const Vector3 &cmp1, const Vector3 &cmp2, const Vector3 &vA, const Vector3 &vB) |
operation r.x = (cmp1.x == cmp2.x) ? vA.x : vB.x per component | |
static Vector3 | CreateSelectCmpGreaterEqual (const Vector3 &cmp1, const Vector3 &cmp2, const Vector3 &vA, const Vector3 &vB) |
operation ( r.x = (cmp1.x >= cmp2.x) ? vA.x : vB.x ) per component | |
static Vector3 | CreateSelectCmpGreater (const Vector3 &cmp1, const Vector3 &cmp2, const Vector3 &vA, const Vector3 &vB) |
operation ( r.x = (cmp1.x > cmp2.x) ? vA.x : vB.x ) per component | |
3-dimensional vector class.
Calculates the closest angle(radians) towards the given vector with in the [0, pi] range. Note: It's unsafe if any of the vectors are (0, 0, 0)
Calculates the closest angle(degrees) towards the given vector with in the [0, 180] range. Note: It's unsafe if any of the vectors are (0, 0, 0)
AZ_MATH_INLINE Vector3 AZ::Vector3::CrossXAxis | ( | ) | const |
Cross product with specified axis.
Returns distance to another Vector3.
AZ_MATH_INLINE Vector3 AZ::Vector3::GetFloor | ( | ) | const |
Floor/Ceil/Round functions, operate on each component individually, result will be a new Vector3.
Min/Max functions, operate on each component individually, result will be a new Vector3.
AZ_MATH_INLINE Vector3 AZ::Vector3::GetNormalizedSafe | ( | float | tolerance = Constants::Tolerance | ) | const |
Safe normalization, returns (0,0,0) if the length of the vector is too small.
Comparison functions, not implemented as operators since that would probably be a little dangerous. These functions return true only if all components pass the comparison test.
Linear interpolation between this vector and a destination.
Normalized linear interpolation between this vector and a destination. Linearly interpolates between the two vectors and normalizes the result.
AZ_MATH_INLINE float AZ::Vector3::NormalizeWithLength | ( | ) |
Normalizes the vector in-place and returns the previous length. This takes a few more instructions than calling just Normalize().
|
static |
AzCore Reflection.
context | reflection context |
Spherical linear interpolation between normalized vectors. Interpolates along the great circle connecting the two vectors.
Stores the vector to an array of 3 floats. The floats need only be 4 byte aligned, 16 byte alignment is NOT required. Note that StoreToFloat4 is usually faster, as the extra padding allows more efficient instructions to be used.
Stores the vector to an array of 4 floats. The floats need only be 4 byte aligned, 16 byte alignment is NOT required. The 4th float is generally set to garbage, but its presence allows more efficient instructions to be used.