nlib
nn::nlib::simd::Vector3 Class Reference

The class with the collection of functions that perform calculations on three-dimensional vectors. All of these functions ignore the values set in lane 3. More...

#include "nn/nlib/simd/SimdVector3.h"

Static Public Member Functions

static bool IsNaN (SimdVectorArg vec) noexcept
 Evaluates whether any of the elements of vec are NaN. More...
 
static bool IsInfinite (SimdVectorArg vec) noexcept
 Evaluates whether any of the elements of vec are positive infinity or negative infinity. More...
 
static bool InBound (SimdVectorArg vec, SimdVectorArg bounds) noexcept
 Evaluates whether the elements of vec are inside the bounds of bounds. More...
 
static f128 Dot (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Calculates the dot product between three-dimensional vectors. More...
 
template<bool SetLane0, bool SetLane1, bool SetLane2, bool SetLane3>
static f128 DotEx (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Calculates the dot product between two three-dimensional vectors and sets the value in the various lanes. More...
 
static SimdVector Cross (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Calculates the cross product between two three-dimensional vectors. More...
 
static SimdVector Normalize (SimdVectorArg vec) noexcept
 Normalizes a three-dimensional vector. More...
 
static SimdVector NormalizeEst (SimdVectorArg vec) noexcept
 Normalizes a three-dimensional vector with relatively low precision. More...
 
static f128 LengthSq (SimdVectorArg vec) noexcept
 Calculates the square of the length of a three-dimensional vector. More...
 
static f128 Length (SimdVectorArg vec) noexcept
 Calculates the length of a three-dimensional vector. More...
 
static f128 LengthEst (SimdVectorArg vec) noexcept
 Calculates the length of a three-dimensional vector with relatively low precision. More...
 
static f128 RecpLength (SimdVectorArg vec) noexcept
 Calculates the reciprocal of the length of a three-dimensional vector. More...
 
static f128 RecpLengthEst (SimdVectorArg vec) noexcept
 Calculates the reciprocal of the length of a three-dimensional vector with relatively low precision. More...
 
static f128 GetAngle (SimdVectorArg vec1_normalized, SimdVectorArg vec2_normalized) noexcept
 Calculates the angle (in radians) between two normalized three-dimensional vectors. More...
 
static SimdVector Reflect (SimdVectorArg vec, SimdVectorArg normal) noexcept
 Reflects a three-dimensional vector using a three-dimensional normal vector. More...
 
static SimdVector Transform (SimdVectorArg vec, SimdMatrixArg m) noexcept
 Transforms a three-dimensional vector using a matrix. (The calculation treats the value of lane 3 (the w element) as 1.) More...
 
static SimdVector TransformCoord (SimdVectorArg vec, SimdMatrixArg m) noexcept
 Transforms a three-dimensional vector using a matrix. (The calculation treats the value of lane 3 (the w element) as 1.) More...
 
static SimdVector TransformNormal (SimdVectorArg vec, SimdMatrixArg m) noexcept
 Transforms a three-dimensional vector using a matrix. (The calculation treats the value of lane 3 (the w element) as 1.) More...
 
static SimdVector Rotate (SimdVectorArg vec, SimdQuaternionArg q_normalized) noexcept
 Rotates a vector using quaternions. More...
 
static SimdVector InvRotate (SimdVectorArg vec, SimdQuaternionArg q_normalized) noexcept
 Rotates a vector in the opposite direction using quaternions. More...
 
Loading and Storing
static SimdVector LoadFloat3 (const Float3 *p) noexcept
 Loads a three-dimensional vector from memory. More...
 
template<typename MyVector3 >
static SimdVector LoadFloat3 (const MyVector3 *p) noexcept
 Loads a three-dimensional vector from memory. More...
 
static void StoreFloat3 (Float3 *p, SimdVectorArg vec) noexcept
 Writes a three-dimensional vector to memory. More...
 
template<typename MyVector3 >
static void StoreFloat3 (MyVector3 *p, SimdVectorArg vec) noexcept
 Writes a three-dimensional vector to memory. More...
 
Comparisons
static bool CmpEq (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Compares two three-dimensional vectors to see if they are equal. More...
 
static bool CmpLt (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Checks to see whether all of the elements of vec1 are smaller than the corresponding elements of vec2. More...
 
static bool CmpLe (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Checks to see whether all of the elements of vec1 are equal or less than the corresponding elements of vec2. More...
 
static bool CmpGt (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Checks to see whether all of the elements of vec1 are larger than the corresponding elements of vec2. More...
 
static bool CmpGe (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Checks to see whether all of the elements of vec1 are equal or greater than the corresponding elements of vec2. More...
 
static bool CmpNe (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Compares vec1 and vec2 to see whether they are unequal. More...
 
static bool CmpNearEq (SimdVectorArg vec1, SimdVectorArg vec2, SimdVectorArg eps) noexcept
 Compares vec1 and vec2 to see whether they are nearly equal. More...
 

Detailed Description

The class with the collection of functions that perform calculations on three-dimensional vectors. All of these functions ignore the values set in lane 3.

Description
It contains only static member functions. In some cases, you can use the functions implemented in the F128 class to perform independent calculations on separate elements.
The class can be used even in environments that do not support SSE or NEON, but with suboptimal performance.
All members of this class are static functions. The class cannot be instantiated.

Definition at line 13 of file SimdVector3.h.

Member Function Documentation

nn::nlib::simd::Vector3::CmpEq ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
staticnoexcept

Compares two three-dimensional vectors to see if they are equal.

Parameters
[in]vec1A three-dimensional vector.
[in]vec2A three-dimensional vector.
Returns
Returns true if the vector elements are the same, and false otherwise.
nn::nlib::simd::Vector3::CmpGe ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
staticnoexcept

Checks to see whether all of the elements of vec1 are equal or greater than the corresponding elements of vec2.

Parameters
[in]vec1A three-dimensional vector.
[in]vec2A three-dimensional vector.
Returns
Returns true if vec1 is equal or greater than vec2, and false otherwise.
nn::nlib::simd::Vector3::CmpGt ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
staticnoexcept

Checks to see whether all of the elements of vec1 are larger than the corresponding elements of vec2.

Parameters
[in]vec1A three-dimensional vector.
[in]vec2A three-dimensional vector.
Returns
Returns true if vec1 is smaller than vec2, and false otherwise.
nn::nlib::simd::Vector3::CmpLe ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
staticnoexcept

Checks to see whether all of the elements of vec1 are equal or less than the corresponding elements of vec2.

Parameters
[in]vec1A three-dimensional vector.
[in]vec2A three-dimensional vector.
Returns
Returns true if vec1 is equal or less than vec2, and false otherwise.
nn::nlib::simd::Vector3::CmpLt ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
staticnoexcept

Checks to see whether all of the elements of vec1 are smaller than the corresponding elements of vec2.

Parameters
[in]vec1A three-dimensional vector.
[in]vec2A three-dimensional vector.
Returns
Returns true if vec1 is smaller than vec2, and false otherwise.
nn::nlib::simd::Vector3::CmpNe ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
staticnoexcept

Compares vec1 and vec2 to see whether they are unequal.

Parameters
[in]vec1A three-dimensional vector.
[in]vec2A three-dimensional vector.
Returns
Returns true if vec1 is not equal to vec2, and false otherwise.
nn::nlib::simd::Vector3::CmpNearEq ( SimdVectorArg  vec1,
SimdVectorArg  vec2,
SimdVectorArg  eps 
)
staticnoexcept

Compares vec1 and vec2 to see whether they are nearly equal.

Parameters
[in]vec1A three-dimensional vector.
[in]vec2A three-dimensional vector.
[in]epsA tolerance value.
Returns
Returns true if vec1 is nearly equal to vec2, and false otherwise.
Description
The process is similar to the following.
return abs(vec1[0] - vec2[0]) <= eps[0] &&
abs(vec1[1] - vec2[1]) <= eps[1] &&
abs(vec1[2] - vec2[2]) <= eps[2];
nn::nlib::simd::Vector3::Cross ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
staticnoexcept

Calculates the cross product between two three-dimensional vectors.

Parameters
[in]vec1A three-dimensional vector.
[in]vec2A three-dimensional vector.
Returns
The three-dimensional vector that is the cross product.
nn::nlib::simd::Vector3::Dot ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
staticnoexcept

Calculates the dot product between three-dimensional vectors.

Parameters
[in]vec1A three-dimensional vector.
[in]vec2A three-dimensional vector.
Returns
The dot product gets stored in each lane, including lane 3.
template<bool SetLane0, bool SetLane1, bool SetLane2, bool SetLane3>
nn::nlib::simd::Vector3::DotEx ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
staticnoexcept

Calculates the dot product between two three-dimensional vectors and sets the value in the various lanes.

Template Parameters
SetLane0Specify true to store the dot product in lane 0, or false to store 0.
SetLane1Specify true to store the dot product in lane 1, or false to store 0.
SetLane2Specify true to store the dot product in lane 2, or false to store 0.
SetLane3Specify true to store the dot product in lane 3, or false to store 0.
Parameters
[in]vec1A three-dimensional vector.
[in]vec2A three-dimensional vector.
Returns
Depending on the values specified for the template parameters, either the dot product or 0.f is stored in each element.
Description
Performs processes similar to those shown in the following pseudocode.
float dot = vec1[0] * vec2[0] + vec1[1] * vec2[1] + vec1[2] * vec2[2];
ret[0] = SetLane0 ? dot : 0.f;
ret[1] = SetLane1 ? dot : 0.f;
ret[2] = SetLane2 ? dot : 0.f;
ret[3] = SetLane3 ? dot : 0.f;
return ret;
nn::nlib::simd::Vector3::GetAngle ( SimdVectorArg  vec1_normalized,
SimdVectorArg  vec2_normalized 
)
staticnoexcept

Calculates the angle (in radians) between two normalized three-dimensional vectors.

Parameters
[in]vec1_normalizedA normalized three-dimensional vector.
[in]vec2_normalizedA normalized three-dimensional vector.
Returns
The angle (in radians) between the three-dimensional vectors is stored in each lane.
nn::nlib::simd::Vector3::InBound ( SimdVectorArg  vec,
SimdVectorArg  bounds 
)
staticnoexcept

Evaluates whether the elements of vec are inside the bounds of bounds.

Parameters
[in]vecA three-dimensional vector.
[in]boundsThe three-dimensional box that defines the bounds.
Returns
Returns true if it is inside the bounds, and false otherwise.
Description
The process is similar to the following.
return abs(vec[0]) <= bounds[0] &&
abs(vec[1]) <= bounds[1] &&
abs(vec[2]) <= bounds[2];
nn::nlib::simd::Vector3::InvRotate ( SimdVectorArg  vec,
SimdQuaternionArg  q_normalized 
)
staticnoexcept

Rotates a vector in the opposite direction using quaternions.

Parameters
[in]vecThe vector to rotate.
[in]q_normalizedNormalized quaternion.
Returns
The vector after it has been rotated.
nn::nlib::simd::Vector3::IsInfinite ( SimdVectorArg  vec)
staticnoexcept

Evaluates whether any of the elements of vec are positive infinity or negative infinity.

Parameters
[in]vecA three-dimensional vector.
Returns
Returns true if vec has any infinite elements, and false otherwise.
nn::nlib::simd::Vector3::IsNaN ( SimdVectorArg  vec)
staticnoexcept

Evaluates whether any of the elements of vec are NaN.

Parameters
[in]vecA three-dimensional vector.
Returns
Returns true if any of the elements of vec are NaN, and false otherwise.
nn::nlib::simd::Vector3::Length ( SimdVectorArg  vec)
staticnoexcept

Calculates the length of a three-dimensional vector.

Parameters
[in]vecA three-dimensional vector.
Returns
The length is stored in each lane.
nn::nlib::simd::Vector3::LengthEst ( SimdVectorArg  vec)
staticnoexcept

Calculates the length of a three-dimensional vector with relatively low precision.

Parameters
[in]vecA three-dimensional vector.
Returns
The length is stored in each lane.
nn::nlib::simd::Vector3::LengthSq ( SimdVectorArg  vec)
staticnoexcept

Calculates the square of the length of a three-dimensional vector.

Parameters
[in]vecA three-dimensional vector.
Returns
The square of the length is stored in each lane.
nn::nlib::simd::Vector3::LoadFloat3 ( const Float3 p)
staticnoexcept

Loads a three-dimensional vector from memory.

Parameters
[in]pPointer to where the three-dimensional vector is stored.
Returns
The three-dimensional vector (the w element is undefined).
template<typename MyVector3 >
nn::nlib::simd::Vector3::LoadFloat3 ( const MyVector3 *  p)
staticnoexcept

Loads a three-dimensional vector from memory.

Template Parameters
MyVector3A structure with a contiguous region in memory for the float-type public data members x, y, and z.
Parameters
[in]pPointer to where the three-dimensional vector is stored.
Returns
The three-dimensional vector (the w element is undefined).
Description
MyVector3 is a class like XMFLOAT3 and XMFLOAT3A in DirectX.
nn::nlib::simd::Vector3::Normalize ( SimdVectorArg  vec)
staticnoexcept

Normalizes a three-dimensional vector.

Parameters
[in]vecA three-dimensional vector.
Returns
The normalized three-dimensional vector.
Description
If vec has infinite length, each element returns a NaN vector. If it has a length of zero, each element returns a 0 vector.
nn::nlib::simd::Vector3::NormalizeEst ( SimdVectorArg  vec)
staticnoexcept

Normalizes a three-dimensional vector with relatively low precision.

Parameters
[in]vecA three-dimensional vector.
Returns
The normalized three-dimensional vector.
nn::nlib::simd::Vector3::RecpLength ( SimdVectorArg  vec)
staticnoexcept

Calculates the reciprocal of the length of a three-dimensional vector.

Parameters
[in]vecA three-dimensional vector.
Returns
The reciprocal of the length is stored in each lane.
nn::nlib::simd::Vector3::RecpLengthEst ( SimdVectorArg  vec)
staticnoexcept

Calculates the reciprocal of the length of a three-dimensional vector with relatively low precision.

Parameters
[in]vecA three-dimensional vector.
Returns
The reciprocal of the length is stored in each lane.
nn::nlib::simd::Vector3::Reflect ( SimdVectorArg  vec,
SimdVectorArg  normal 
)
staticnoexcept

Reflects a three-dimensional vector using a three-dimensional normal vector.

Parameters
[in]vecThe three-dimensional vector to reflect.
[in]normalThe three-dimensional normal vector (unit vector).
Returns
Returns the reflected three-dimensional vector.
nn::nlib::simd::Vector3::Rotate ( SimdVectorArg  vec,
SimdQuaternionArg  q_normalized 
)
staticnoexcept

Rotates a vector using quaternions.

Parameters
[in]vecThe vector to rotate.
[in]q_normalizedNormalized quaternion.
Returns
The vector after it has been rotated.
nn::nlib::simd::Vector3::StoreFloat3 ( Float3 p,
SimdVectorArg  vec 
)
staticnoexcept

Writes a three-dimensional vector to memory.

Parameters
[in,out]pPointer to where the three-dimensional vector is stored.
[in]vecA three-dimensional vector. (The w element is not stored in memory.)
template<typename MyVector3 >
nn::nlib::simd::Vector3::StoreFloat3 ( MyVector3 *  p,
SimdVectorArg  vec 
)
staticnoexcept

Writes a three-dimensional vector to memory.

Template Parameters
MyVector3A structure with a contiguous region in memory for the float-type public data members x, y, and z.
Parameters
[in,out]pPointer to where the three-dimensional vector is stored.
[in]vecA three-dimensional vector. (The w element is not stored in memory.)
Description
MyVector3 is a class like XMFLOAT3 and XMFLOAT3A in DirectX.
nn::nlib::simd::Vector3::Transform ( SimdVectorArg  vec,
SimdMatrixArg  m 
)
staticnoexcept

Transforms a three-dimensional vector using a matrix. (The calculation treats the value of lane 3 (the w element) as 1.)

Parameters
[in]vecA three-dimensional vector.
[in]mThe transform matrix.
Returns
The transformed three-dimensional vector.
Description
The calculation uses 1 for the value of lane 3 (the w element) of the vec argument. The vector that results from the calculation does not usually have homogenous coordinates. (Lane 3 (element w) is probably not 1.0.)
nn::nlib::simd::Vector3::TransformCoord ( SimdVectorArg  vec,
SimdMatrixArg  m 
)
staticnoexcept

Transforms a three-dimensional vector using a matrix. (The calculation treats the value of lane 3 (the w element) as 1.)

Parameters
[in]vecA three-dimensional vector.
[in]mThe transform matrix.
Returns
The transformed four-dimensional vector (a homogenous vector).
Description
The calculation uses 1 for the value of lane 3 (the w element) of the vec argument. The vector that results from the calculation has homogenous coordinates. (Lane 3 (element w) is 1.0.)
nn::nlib::simd::Vector3::TransformNormal ( SimdVectorArg  vec,
SimdMatrixArg  m 
)
staticnoexcept

Transforms a three-dimensional vector using a matrix. (The calculation treats the value of lane 3 (the w element) as 1.)

Parameters
[in]vecA three-dimensional vector.
[in]mThe transform matrix.
Returns
The transformed three-dimensional vector.

The documentation for this class was generated from the following files: