Loading...
Searching...
No Matches
GfVec4f Class Reference

Basic type for a vector of 4 float components. More...

#include <vec4f.h>

Public Types

typedef float ScalarType
 Scalar element type and dimension.
 

Public Member Functions

 GfVec4f ()=default
 Default constructor does no initialization.
 
constexpr GfVec4f (float value)
 Initialize all elements to a single value.
 
constexpr GfVec4f (float s0, float s1, float s2, float s3)
 Initialize all elements with explicit arguments.
 
template<class Scl >
constexpr GfVec4f (Scl const *p)
 Construct with pointer to values.
 
 GfVec4f (class GfVec4d const &other)
 Construct from GfVec4d.
 
 GfVec4f (class GfVec4h const &other)
 Implicitly convert from GfVec4h.
 
 GfVec4f (class GfVec4i const &other)
 Implicitly convert from GfVec4i.
 
GfVec4fSet (float s0, float s1, float s2, float s3)
 Set all elements with passed arguments.
 
GfVec4fSet (float const *a)
 Set all elements with a pointer to data.
 
float const * data () const
 Direct data access.
 
float * data ()
 
float const * GetArray () const
 
float const & operator[] (size_t i) const
 Indexing.
 
float & operator[] (size_t i)
 
bool operator== (GfVec4f const &other) const
 Equality comparison.
 
bool operator!= (GfVec4f const &other) const
 
GF_API bool operator== (class GfVec4d const &other) const
 Equality comparison.
 
GF_API bool operator== (class GfVec4h const &other) const
 Equality comparison.
 
GF_API bool operator== (class GfVec4i const &other) const
 Equality comparison.
 
GfVec4f operator- () const
 Create a vec with negated elements.
 
GfVec4foperator+= (GfVec4f const &other)
 Addition.
 
GfVec4foperator-= (GfVec4f const &other)
 Subtraction.
 
GfVec4foperator*= (double s)
 Multiplication by scalar.
 
GfVec4f operator* (double s) const
 
GfVec4foperator/= (double s)
 Division by scalar.
 
GfVec4f operator/ (double s) const
 
float operator* (GfVec4f const &v) const
 See GfDot().
 
GfVec4f GetProjection (GfVec4f const &v) const
 Returns the projection of this onto v.
 
GfVec4f GetComplement (GfVec4f const &b) const
 Returns the orthogonal complement of this->GetProjection(b).
 
float GetLengthSq () const
 Squared length.
 
float GetLength () const
 Length.
 
float Normalize (float eps=GF_MIN_VECTOR_LENGTH)
 Normalizes the vector in place to unit length, returning the length before normalization.
 
GfVec4f GetNormalized (float eps=GF_MIN_VECTOR_LENGTH) const
 

Static Public Member Functions

static GfVec4f XAxis ()
 Create a unit vector along the X-axis.
 
static GfVec4f YAxis ()
 Create a unit vector along the Y-axis.
 
static GfVec4f ZAxis ()
 Create a unit vector along the Z-axis.
 
static GfVec4f WAxis ()
 Create a unit vector along the W-axis.
 
static GfVec4f Axis (size_t i)
 Create a unit vector along the i-th axis, zero-based.
 

Static Public Attributes

static const size_t dimension = 4
 

Friends

size_t hash_value (GfVec4f const &vec)
 Hash.
 
GfVec4f operator+ (GfVec4f const &l, GfVec4f const &r)
 
GfVec4f operator- (GfVec4f const &l, GfVec4f const &r)
 
GfVec4f operator* (double s, GfVec4f const &v)
 

Detailed Description

Basic type for a vector of 4 float components.

Represents a vector of 4 components of type float. It is intended to be fast and simple.

Definition at line 62 of file vec4f.h.

Member Typedef Documentation

◆ ScalarType

typedef float ScalarType

Scalar element type and dimension.

Definition at line 66 of file vec4f.h.

Constructor & Destructor Documentation

◆ GfVec4f() [1/7]

GfVec4f ( )
default

Default constructor does no initialization.

◆ GfVec4f() [2/7]

constexpr GfVec4f ( float  value)
inlineexplicitconstexpr

Initialize all elements to a single value.

Definition at line 73 of file vec4f.h.

◆ GfVec4f() [3/7]

constexpr GfVec4f ( float  s0,
float  s1,
float  s2,
float  s3 
)
inlineconstexpr

Initialize all elements with explicit arguments.

Definition at line 79 of file vec4f.h.

◆ GfVec4f() [4/7]

constexpr GfVec4f ( Scl const *  p)
inlineexplicitconstexpr

Construct with pointer to values.

Definition at line 86 of file vec4f.h.

◆ GfVec4f() [5/7]

GfVec4f ( class GfVec4d const &  other)
inlineexplicit

Construct from GfVec4d.

Definition at line 313 of file vec4f.h.

◆ GfVec4f() [6/7]

GfVec4f ( class GfVec4h const &  other)
inline

Implicitly convert from GfVec4h.

Definition at line 321 of file vec4f.h.

◆ GfVec4f() [7/7]

GfVec4f ( class GfVec4i const &  other)
inline

Implicitly convert from GfVec4i.

Definition at line 329 of file vec4f.h.

Member Function Documentation

◆ Axis()

static GfVec4f Axis ( size_t  i)
inlinestatic

Create a unit vector along the i-th axis, zero-based.

Return the zero vector if i is greater than or equal to 4.

Definition at line 127 of file vec4f.h.

◆ data() [1/2]

float * data ( )
inline

Definition at line 150 of file vec4f.h.

◆ data() [2/2]

float const * data ( ) const
inline

Direct data access.

Definition at line 149 of file vec4f.h.

◆ GetArray()

float const * GetArray ( ) const
inline

Definition at line 151 of file vec4f.h.

◆ GetComplement()

GfVec4f GetComplement ( GfVec4f const &  b) const
inline

Returns the orthogonal complement of this->GetProjection(b).

That is:

*this - this->GetProjection(b)
GfVec4f GetProjection(GfVec4f const &v) const
Returns the projection of this onto v.
Definition: vec4f.h:249

Definition at line 258 of file vec4f.h.

◆ GetLength()

float GetLength ( ) const
inline

Length.

Definition at line 268 of file vec4f.h.

◆ GetLengthSq()

float GetLengthSq ( ) const
inline

Squared length.

Definition at line 263 of file vec4f.h.

◆ GetNormalized()

GfVec4f GetNormalized ( float  eps = GF_MIN_VECTOR_LENGTH) const
inline

Definition at line 288 of file vec4f.h.

◆ GetProjection()

GfVec4f GetProjection ( GfVec4f const &  v) const
inline

Returns the projection of this onto v.

That is:

v * (*this * v)

Definition at line 249 of file vec4f.h.

◆ Normalize()

float Normalize ( float  eps = GF_MIN_VECTOR_LENGTH)
inline

Normalizes the vector in place to unit length, returning the length before normalization.

If the length of the vector is smaller than eps, then the vector is set to vector/eps. The original length of the vector is returned. See also GfNormalize().

Definition at line 280 of file vec4f.h.

◆ operator!=()

bool operator!= ( GfVec4f const &  other) const
inline

Definition at line 169 of file vec4f.h.

◆ operator*() [1/2]

GfVec4f operator* ( double  s) const
inline

Definition at line 221 of file vec4f.h.

◆ operator*() [2/2]

float operator* ( GfVec4f const &  v) const
inline

See GfDot().

Definition at line 241 of file vec4f.h.

◆ operator*=()

GfVec4f & operator*= ( double  s)
inline

Multiplication by scalar.

Definition at line 214 of file vec4f.h.

◆ operator+=()

GfVec4f & operator+= ( GfVec4f const &  other)
inline

Addition.

Definition at line 190 of file vec4f.h.

◆ operator-()

GfVec4f operator- ( ) const
inline

Create a vec with negated elements.

Definition at line 185 of file vec4f.h.

◆ operator-=()

GfVec4f & operator-= ( GfVec4f const &  other)
inline

Subtraction.

Definition at line 202 of file vec4f.h.

◆ operator/()

GfVec4f operator/ ( double  s) const
inline

Definition at line 236 of file vec4f.h.

◆ operator/=()

GfVec4f & operator/= ( double  s)
inline

Division by scalar.

Definition at line 230 of file vec4f.h.

◆ operator==() [1/4]

GF_API bool operator== ( class GfVec4d const &  other) const

Equality comparison.

◆ operator==() [2/4]

GF_API bool operator== ( class GfVec4h const &  other) const

Equality comparison.

◆ operator==() [3/4]

GF_API bool operator== ( class GfVec4i const &  other) const

Equality comparison.

◆ operator==() [4/4]

bool operator== ( GfVec4f const &  other) const
inline

Equality comparison.

Definition at line 163 of file vec4f.h.

◆ operator[]() [1/2]

float & operator[] ( size_t  i)
inline

Definition at line 155 of file vec4f.h.

◆ operator[]() [2/2]

float const & operator[] ( size_t  i) const
inline

Indexing.

Definition at line 154 of file vec4f.h.

◆ Set() [1/2]

GfVec4f & Set ( float const *  a)
inline

Set all elements with a pointer to data.

Definition at line 144 of file vec4f.h.

◆ Set() [2/2]

GfVec4f & Set ( float  s0,
float  s1,
float  s2,
float  s3 
)
inline

Set all elements with passed arguments.

Definition at line 135 of file vec4f.h.

◆ WAxis()

static GfVec4f WAxis ( )
inlinestatic

Create a unit vector along the W-axis.

Definition at line 119 of file vec4f.h.

◆ XAxis()

static GfVec4f XAxis ( )
inlinestatic

Create a unit vector along the X-axis.

Definition at line 101 of file vec4f.h.

◆ YAxis()

static GfVec4f YAxis ( )
inlinestatic

Create a unit vector along the Y-axis.

Definition at line 107 of file vec4f.h.

◆ ZAxis()

static GfVec4f ZAxis ( )
inlinestatic

Create a unit vector along the Z-axis.

Definition at line 113 of file vec4f.h.

Friends And Related Function Documentation

◆ hash_value

size_t hash_value ( GfVec4f const &  vec)
friend

Hash.

Definition at line 158 of file vec4f.h.

◆ operator*

GfVec4f operator* ( double  s,
GfVec4f const &  v 
)
friend

Definition at line 224 of file vec4f.h.

◆ operator+

GfVec4f operator+ ( GfVec4f const &  l,
GfVec4f const &  r 
)
friend

Definition at line 197 of file vec4f.h.

◆ operator-

GfVec4f operator- ( GfVec4f const &  l,
GfVec4f const &  r 
)
friend

Definition at line 209 of file vec4f.h.

Member Data Documentation

◆ dimension

const size_t dimension = 4
static

Definition at line 67 of file vec4f.h.


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