Vec3_tpl

#include

Inherits INumberVector< F, 3, Vec3_tpl< F > >.

Public Types

typedef INumberVector< F, 3, Vec3_tpl< F > > NV

Public Member Functions

ILINE Vec3_tpl (type_zero)
ILINE Vec3_tpl (F s)
template
ILINE Vec3_tpl (const Vec3_tpl< F2 > &in)
Vec3_tpl (type_min)
Vec3_tpl (type_max)
ILINE Vec3_tpl (F vx, F vy, F vz)
ILINE void operator() (F vx, F vy, F vz)
ILINE Vec3_tpl< F > & Set (const F xval, const F yval, const F zval)
ILINE Vec3_tpl (const Vec2_tpl< F > &v, F vz=0)
template
ILINE Vec3_tpl (const Vec2_tpl< F2 > &v, F2 vz=0)
ILINE operator const Vec2_tpl< F > & () const
ILINE bool operator== (const Vec3_tpl< F > &o) const
ILINE bool operator!= (const Vec3_tpl< F > &o) const
ILINE Vec3_tpl< F > & Flip ()
ILINE bool IsZeroFast (F e=(F) 0.0003) const
ILINE bool IsUnit (f32 epsilon=VEC_EPSILON) const
ILINE void SetLength (F fLen)
force vector length by normalizing it
ILINE void ClampLength (F maxLength)
ILINE F GetLength2D () const
calculate the length of the vector ignoring the z component
ILINE F GetLengthSquared2D () const
calculate the squared length of the vector ignoring the z component
ILINE F GetSquaredDistance2D (const Vec3_tpl< F > &v) const
ILINE F NormalizeSafe (const Vec3_tpl< F > &safe=Vec3Constants< F >::fVec3_Zero)
ILINE Vec3_tpl GetNormalizedSafe (const Vec3_tpl< F > &safe=Vec3Constants< F >::fVec3_OneX) const
return a safely normalized vector - returns safe vector (should be normalised) if original is zero length
ILINE Vec3_tpl GetPermutated (int new_z) const
Permutate coordinates so that z goes to new_z slot.
ILINE F GetVolume () const
ILINE Vec3_tpl< F > abs () const
ILINE void CheckMin (const Vec3_tpl< F > &other)
check for min bounds
ILINE void CheckMax (const Vec3_tpl< F > &other)
check for max bounds
ILINE void SetOrthogonal (const Vec3_tpl< F > &v)
ILINE Vec3_tpl GetOrthogonal () const
ILINE void SetProjection (const Vec3_tpl &i, const Vec3_tpl &n)
ILINE Vec3_tpl ProjectionOn (const Vec3_tpl &b) const
ILINE void SetReflection (const Vec3_tpl< F > &i, const Vec3_tpl< F > &n)
ILINE void SetLerp (const Vec3_tpl< F > &p, const Vec3_tpl< F > &q, F t)
void SetSlerp (const Vec3_tpl< F > &p, const Vec3_tpl< F > &q, F t)
ILINE void SetQuadraticCurve (const Vec3_tpl< F > &v0, const Vec3_tpl< F > &v1, const Vec3_tpl< F > &v2, F t1)
ILINE void SetCubicCurve (const Vec3_tpl< F > &v0, const Vec3_tpl< F > &v1, const Vec3_tpl< F > &v2, const Vec3_tpl< F > &v3, F t1)
ILINE void SetQuadraticSpline (const Vec3_tpl< F > &v0, const Vec3_tpl< F > &v1, const Vec3_tpl< F > &v2, F t)
ILINE Vec3_tpl< F > GetRotated (const Vec3_tpl< F > &axis, F angle) const
ILINE Vec3_tpl< F > GetRotated (const Vec3_tpl< F > &axis, F cosa, F sina) const
ILINE Vec3_tpl< F > GetRotated (const Vec3_tpl &center, const Vec3_tpl< F > &axis, F angle) const
ILINE Vec3_tpl< F > GetRotated (const Vec3_tpl< F > &center, const Vec3_tpl< F > &axis, F cosa, F sina) const
ILINE Vec3_tpl CompMul (const Vec3_tpl< F > &rhs) const
Component-wise multiplication of two vectors.
ILINE F Dot (const Vec2_tpl< F > &v) const
ILINE Vec3_tpl< F > Cross (const Vec3_tpl< F > &vec2) const
Two methods for a "cross-product" operation.
CRY_DEPRECATED ("Use begin() instead") operator F*()
template
CRY_DEPRECATED ("Use Vec3_tpl(const Vec3_tpl&) instead") explicit Vec3_tpl(const T *src)
ILINE Vec3_tpl & zero ()
ILINE F len () const
ILINE F len2 () const
ILINE Vec3_tpl & normalize ()
ILINE Vec3_tpl normalized () const
template
ILINE Vec3_tpl< F1 > sub (const Vec3_tpl< F1 > &v) const
Vector subtraction.
template
ILINE Vec3_tpl< F1 > scale (const F1 k) const
Vector scale.
template
ILINE F1 dot (const Vec3_tpl< F1 > &v) const
Vector dot product.
template
ILINE Vec3_tpl< F1 > cross (const Vec3_tpl< F1 > &v) const
Vector cross product.
template<>
Vec3_tpl (type_min)
template<>
Vec3_tpl (type_max)

Static Public Member Functions

static ILINE bool IsEquivalent (const Vec3_tpl< F > &v0, const Vec3_tpl< F > &v1, f32 epsilon=VEC_EPSILON)
static ILINE Vec3_tpl< F > CreateProjection (const Vec3_tpl &i, const Vec3_tpl &n)
static ILINE Vec3_tpl< F > CreateReflection (const Vec3_tpl< F > &i, const Vec3_tpl< F > &n)
static ILINE Vec3_tpl< F > CreateLerp (const Vec3_tpl< F > &p, const Vec3_tpl< F > &q, F t)
static ILINE Vec3_tpl< F > CreateSlerp (const Vec3_tpl< F > &p, const Vec3_tpl< F > &q, F t)
static ILINE Vec3_tpl< F > CreateQuadraticCurve (const Vec3_tpl< F > &v0, const Vec3_tpl< F > &v1, const Vec3_tpl< F > &v2, F t)
static ILINE Vec3_tpl< F > CreateCubicCurve (const Vec3_tpl< F > &v0, const Vec3_tpl< F > &v1, const Vec3_tpl< F > &v2, const Vec3_tpl< F > &v3, F t)
static ILINE Vec3_tpl< F > CreateQuadraticSpline (const Vec3_tpl< F > &v0, const Vec3_tpl< F > &v1, const Vec3_tpl< F > &v2, F t)

Public Attributes

F x
F y
F z
AUTO_STRUCT_INFO

Detailed Description

template struct Vec3_tpl< F >

General-purpose 3D vector implementation

See also
Vec3, Vec3i

Constructor & Destructor Documentation

◆ Vec3_tpl() [1/2]

template
Vec3_tpl< F >::Vec3_tpl ( type_min )

Template specialization to initialize a vector. Example: Vec3 v0=Vec3(ZERO); Vec3 v1=Vec3(MIN); Vec3 v2=Vec3(MAX);

◆ Vec3_tpl() [2/2]

template
ILINE Vec3_tpl< F >::Vec3_tpl ( F vx,
F vy,
F vz
)
inline

Constructors and bracket-operator to initialize a vector. Example: Vec3 v0=Vec3(1,2,3); Vec3 v1(1,2,3); v2.Set(1,2,3);

Member Function Documentation

◆ abs()

template
ILINE Vec3_tpl Vec3_tpl< F >::abs ( ) const
inline
Returns
A vector that consists of absolute values of this one's coordinates.

◆ Flip()

template
ILINE Vec3_tpl& Vec3_tpl< F >::Flip ( )
inline

Overloaded arithmetic operator. Example: Vec3 v0=v1*4;

◆ GetOrthogonal()

template
ILINE Vec3_tpl Vec3_tpl< F >::GetOrthogonal ( ) const
inline
Returns
A vector orthogonal to this one.

◆ GetRotated() [1/2]

template
ILINE Vec3_tpl Vec3_tpl< F >::GetRotated ( const Vec3_tpl< F > & axis,
F angle
) const
inline

Rotate a vector using angle and axis. Example: Vec3 r=v.GetRotated(axis,angle);

◆ GetRotated() [2/2]

template
ILINE Vec3_tpl Vec3_tpl< F >::GetRotated ( const Vec3_tpl< F > & center,
const Vec3_tpl< F > & axis,
F angle
) const
inline

Rotate a vector around a center using angle and axis. Example: Vec3 r=v.GetRotated(axis,angle);

◆ GetVolume()

template
ILINE F Vec3_tpl< F >::GetVolume ( ) const
inline
Returns
Volume of a box with this vector as diagonal.

◆ NormalizeSafe()

template
ILINE F Vec3_tpl< F >::NormalizeSafe ( const Vec3_tpl< F > & safe = Vec3Constants::fVec3_Zero)
inline

Normalize the vector. Check for null vector - set to the passed in vector (which should be normalised!) if it is null vector.

Returns
The original length of the vector.

◆ SetCubicCurve()

template
ILINE void Vec3_tpl< F >::SetCubicCurve ( const Vec3_tpl< F > & v0,
const Vec3_tpl< F > & v1,
const Vec3_tpl< F > & v2,
const Vec3_tpl< F > & v3,
F t1
)
inline

Cubic-Interpolation between vectors v0,v1,v2,v3. This is repeated linear interpolation from 4 points. If t is in the range [0...1], then the curve goes only through v0 and v3. Example: Vec3 ip; ip.SetCubicCurve( v0,v1,v2,v3, 0.345f );

◆ SetLerp()

template
ILINE void Vec3_tpl< F >::SetLerp ( const Vec3_tpl< F > & p,
const Vec3_tpl< F > & q,
F t
)
inline

Linear-Interpolation between Vec3 (lerp). Example: Vec3 r=Vec3::CreateLerp( p, q, 0.345f );

◆ SetOrthogonal()

template
ILINE void Vec3_tpl< F >::SetOrthogonal ( const Vec3_tpl< F > & v)
inline

sets a vector orthogonal to the input vector

Example: Vec3 v; v.SetOrthogonal( i );

◆ SetProjection()

template
ILINE void Vec3_tpl< F >::SetProjection ( const Vec3_tpl< F > & i,
const Vec3_tpl< F > & n
)
inline

Project a point/vector on a (virtual) plane. Consider we have a plane going through the origin. Because d=0 we need just the normal. The vector n is assumed to be a unit-vector. Example: Vec3 result=Vec3::CreateProjection( incident, normal );

◆ SetQuadraticCurve()

template
ILINE void Vec3_tpl< F >::SetQuadraticCurve ( const Vec3_tpl< F > & v0,
const Vec3_tpl< F > & v1,
const Vec3_tpl< F > & v2,
F t1
)
inline

Quadratic-Interpolation between vectors v0,v1,v2. This is repeated linear interpolation from 3 points and the resulting curve is a parabola. If t is in the range [0...1], then the curve goes only through v0 and v2. Example: Vec3 ip; ip.SetQuadraticCurve( v0,v1,v2, 0.345f );

◆ SetQuadraticSpline()

template
ILINE void Vec3_tpl< F >::SetQuadraticSpline ( const Vec3_tpl< F > & v0,
const Vec3_tpl< F > & v1,
const Vec3_tpl< F > & v2,
F t
)
inline

Spline-Interpolation between vectors v0,v1,v2. This is a variation of a quadratic curve. If t is in the range [0...1], then the spline goes through all 3 points. Example: Vec3 ip; ip.SetSplineInterpolation( v0,v1,v2, 0.345f );

◆ SetReflection()

template
ILINE void Vec3_tpl< F >::SetReflection ( const Vec3_tpl< F > & i,
const Vec3_tpl< F > & n
)
inline

Calculate a reflection vector. Vec3 n is assumed to be a unit-vector. Example: Vec3 result=Vec3::CreateReflection( incident, normal );

◆ SetSlerp()

template
void Vec3_tpl< F >::SetSlerp ( const Vec3_tpl< F > & p,
const Vec3_tpl< F > & q,
F t
)
inline

Spherical-Interpolation between 3d-vectors (geometrical slerp) both vectors are assumed to be normalized. Example: Vec3 r=Vec3::CreateSlerp( p, q, 0.5674f );