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
 GfVec4f value-initializes to zero and performs no default initialization, like float or double.
 
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
 
Swizzles

Each accessor returns a new vector built from this one's components, in the order named.

For example wzyx() returns GfVec4f(w, z, y, x).

Every permutation of 2 to 4 of the 4 components is available. Repeated components (xx, xyy) are not; nor are single-component swizzles, which are just the components themselves.

The results are ordinary GfVecs, so all the usual operators, GfDot() and so on apply to them. They are values, not references into this vector, so they cannot be assigned through.

constexpr GfVec2f xy () const
 
constexpr GfVec2f xz () const
 
constexpr GfVec2f xw () const
 
constexpr GfVec2f yx () const
 
constexpr GfVec2f yz () const
 
constexpr GfVec2f yw () const
 
constexpr GfVec2f zx () const
 
constexpr GfVec2f zy () const
 
constexpr GfVec2f zw () const
 
constexpr GfVec2f wx () const
 
constexpr GfVec2f wy () const
 
constexpr GfVec2f wz () const
 
constexpr GfVec3f xyz () const
 
constexpr GfVec3f xyw () const
 
constexpr GfVec3f xzy () const
 
constexpr GfVec3f xzw () const
 
constexpr GfVec3f xwy () const
 
constexpr GfVec3f xwz () const
 
constexpr GfVec3f yxz () const
 
constexpr GfVec3f yxw () const
 
constexpr GfVec3f yzx () const
 
constexpr GfVec3f yzw () const
 
constexpr GfVec3f ywx () const
 
constexpr GfVec3f ywz () const
 
constexpr GfVec3f zxy () const
 
constexpr GfVec3f zxw () const
 
constexpr GfVec3f zyx () const
 
constexpr GfVec3f zyw () const
 
constexpr GfVec3f zwx () const
 
constexpr GfVec3f zwy () const
 
constexpr GfVec3f wxy () const
 
constexpr GfVec3f wxz () const
 
constexpr GfVec3f wyx () const
 
constexpr GfVec3f wyz () const
 
constexpr GfVec3f wzx () const
 
constexpr GfVec3f wzy () const
 
constexpr GfVec4f xyzw () const
 
constexpr GfVec4f xywz () const
 
constexpr GfVec4f xzyw () const
 
constexpr GfVec4f xzwy () const
 
constexpr GfVec4f xwyz () const
 
constexpr GfVec4f xwzy () const
 
constexpr GfVec4f yxzw () const
 
constexpr GfVec4f yxwz () const
 
constexpr GfVec4f yzxw () const
 
constexpr GfVec4f yzwx () const
 
constexpr GfVec4f ywxz () const
 
constexpr GfVec4f ywzx () const
 
constexpr GfVec4f zxyw () const
 
constexpr GfVec4f zxwy () const
 
constexpr GfVec4f zyxw () const
 
constexpr GfVec4f zywx () const
 
constexpr GfVec4f zwxy () const
 
constexpr GfVec4f zwyx () const
 
constexpr GfVec4f wxyz () const
 
constexpr GfVec4f wxzy () const
 
constexpr GfVec4f wyxz () const
 
constexpr GfVec4f wyzx () const
 
constexpr GfVec4f wzxy () const
 
constexpr GfVec4f wzyx () 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.
 

Public Attributes

Vector Components

The vector's components, which are also its storage.

These are public and directly readable and writable.

The components are contiguous and in declaration order, so &x points to dimension values. See data() and operator[]().

For multi-component access see the swizzle accessors below, which return a new vector by value.

float x
 
float y
 
float z
 
float w
 

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 47 of file vec4f.h.

Member Typedef Documentation

◆ ScalarType

float ScalarType

Scalar element type and dimension.

Definition at line 51 of file vec4f.h.

Constructor & Destructor Documentation

◆ GfVec4f() [1/7]

GfVec4f ( )
default

GfVec4f value-initializes to zero and performs no default initialization, like float or double.

◆ GfVec4f() [2/7]

GfVec4f ( float value)
inlineexplicitconstexpr

Initialize all elements to a single value.

Definition at line 73 of file vec4f.h.

◆ GfVec4f() [3/7]

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]

template<class Scl >
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 464 of file vec4f.h.

◆ GfVec4f() [6/7]

GfVec4f ( class GfVec4h const & other)
inline

Implicitly convert from GfVec4h.

Definition at line 472 of file vec4f.h.

◆ GfVec4f() [7/7]

GfVec4f ( class GfVec4i const & other)
inline

Implicitly convert from GfVec4i.

Definition at line 480 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 129 of file vec4f.h.

◆ data() [1/2]

float * data ( )
inline

Definition at line 156 of file vec4f.h.

◆ data() [2/2]

float const * data ( ) const
inline

Direct data access.

data() is the only member that relies on the components being contiguous; every other member either names them directly or goes through here.

Definition at line 155 of file vec4f.h.

◆ GetArray()

float const * GetArray ( ) const
inline

Definition at line 157 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:255

Definition at line 264 of file vec4f.h.

◆ GetLength()

float GetLength ( ) const
inline

Length.

Definition at line 274 of file vec4f.h.

◆ GetLengthSq()

float GetLengthSq ( ) const
inline

Squared length.

Definition at line 269 of file vec4f.h.

◆ GetNormalized()

GfVec4f GetNormalized ( float eps = GF_MIN_VECTOR_LENGTH) const
inline

Definition at line 294 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 255 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 286 of file vec4f.h.

◆ operator!=()

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

Definition at line 175 of file vec4f.h.

◆ operator*() [1/2]

GfVec4f operator* ( double s) const
inline

Definition at line 227 of file vec4f.h.

◆ operator*() [2/2]

float operator* ( GfVec4f const & v) const
inline

See GfDot().

Definition at line 247 of file vec4f.h.

◆ operator*=()

GfVec4f & operator*= ( double s)
inline

Multiplication by scalar.

Definition at line 220 of file vec4f.h.

◆ operator+=()

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

Addition.

Definition at line 196 of file vec4f.h.

◆ operator-()

GfVec4f operator- ( ) const
inline

Create a vec with negated elements.

Definition at line 191 of file vec4f.h.

◆ operator-=()

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

Subtraction.

Definition at line 208 of file vec4f.h.

◆ operator/()

GfVec4f operator/ ( double s) const
inline

Definition at line 242 of file vec4f.h.

◆ operator/=()

GfVec4f & operator/= ( double s)
inline

Division by scalar.

Definition at line 236 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 169 of file vec4f.h.

◆ operator[]() [1/2]

float & operator[] ( size_t i)
inline

Definition at line 161 of file vec4f.h.

◆ operator[]() [2/2]

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

Indexing.

Definition at line 160 of file vec4f.h.

◆ Set() [1/2]

GfVec4f & Set ( float const * a)
inline

Set all elements with a pointer to data.

Definition at line 146 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 137 of file vec4f.h.

◆ WAxis()

static GfVec4f WAxis ( )
inlinestatic

Create a unit vector along the W-axis.

Definition at line 121 of file vec4f.h.

◆ wx()

Vec wx ( ) const
constexpr

Definition at line 562 of file vec4f.h.

◆ wxy()

Vec wxy ( ) const
constexpr

Definition at line 730 of file vec4f.h.

◆ wxyz()

Vec wxyz ( ) const
constexpr

Definition at line 922 of file vec4f.h.

◆ wxz()

Vec wxz ( ) const
constexpr

Definition at line 738 of file vec4f.h.

◆ wxzy()

Vec wxzy ( ) const
constexpr

Definition at line 930 of file vec4f.h.

◆ wy()

Vec wy ( ) const
constexpr

Definition at line 570 of file vec4f.h.

◆ wyx()

Vec wyx ( ) const
constexpr

Definition at line 746 of file vec4f.h.

◆ wyxz()

Vec wyxz ( ) const
constexpr

Definition at line 938 of file vec4f.h.

◆ wyz()

Vec wyz ( ) const
constexpr

Definition at line 754 of file vec4f.h.

◆ wyzx()

Vec wyzx ( ) const
constexpr

Definition at line 946 of file vec4f.h.

◆ wz()

Vec wz ( ) const
constexpr

Definition at line 578 of file vec4f.h.

◆ wzx()

Vec wzx ( ) const
constexpr

Definition at line 762 of file vec4f.h.

◆ wzxy()

Vec wzxy ( ) const
constexpr

Definition at line 954 of file vec4f.h.

◆ wzy()

Vec wzy ( ) const
constexpr

Definition at line 770 of file vec4f.h.

◆ wzyx()

Vec wzyx ( ) const
constexpr

Definition at line 962 of file vec4f.h.

◆ XAxis()

static GfVec4f XAxis ( )
inlinestatic

Create a unit vector along the X-axis.

Definition at line 100 of file vec4f.h.

◆ xw()

Vec xw ( ) const
constexpr

Definition at line 506 of file vec4f.h.

◆ xwy()

Vec xwy ( ) const
constexpr

Definition at line 618 of file vec4f.h.

◆ xwyz()

Vec xwyz ( ) const
constexpr

Definition at line 810 of file vec4f.h.

◆ xwz()

Vec xwz ( ) const
constexpr

Definition at line 626 of file vec4f.h.

◆ xwzy()

Vec xwzy ( ) const
constexpr

Definition at line 818 of file vec4f.h.

◆ xy()

Vec xy ( ) const
constexpr

Definition at line 490 of file vec4f.h.

◆ xyw()

Vec xyw ( ) const
constexpr

Definition at line 594 of file vec4f.h.

◆ xywz()

Vec xywz ( ) const
constexpr

Definition at line 786 of file vec4f.h.

◆ xyz()

Vec xyz ( ) const
constexpr

Definition at line 586 of file vec4f.h.

◆ xyzw()

Vec xyzw ( ) const
constexpr

Definition at line 778 of file vec4f.h.

◆ xz()

Vec xz ( ) const
constexpr

Definition at line 498 of file vec4f.h.

◆ xzw()

Vec xzw ( ) const
constexpr

Definition at line 610 of file vec4f.h.

◆ xzwy()

Vec xzwy ( ) const
constexpr

Definition at line 802 of file vec4f.h.

◆ xzy()

Vec xzy ( ) const
constexpr

Definition at line 602 of file vec4f.h.

◆ xzyw()

Vec xzyw ( ) const
constexpr

Definition at line 794 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.

◆ yw()

Vec yw ( ) const
constexpr

Definition at line 530 of file vec4f.h.

◆ ywx()

Vec ywx ( ) const
constexpr

Definition at line 666 of file vec4f.h.

◆ ywxz()

Vec ywxz ( ) const
constexpr

Definition at line 858 of file vec4f.h.

◆ ywz()

Vec ywz ( ) const
constexpr

Definition at line 674 of file vec4f.h.

◆ ywzx()

Vec ywzx ( ) const
constexpr

Definition at line 866 of file vec4f.h.

◆ yx()

Vec yx ( ) const
constexpr

Definition at line 514 of file vec4f.h.

◆ yxw()

Vec yxw ( ) const
constexpr

Definition at line 642 of file vec4f.h.

◆ yxwz()

Vec yxwz ( ) const
constexpr

Definition at line 834 of file vec4f.h.

◆ yxz()

Vec yxz ( ) const
constexpr

Definition at line 634 of file vec4f.h.

◆ yxzw()

Vec yxzw ( ) const
constexpr

Definition at line 826 of file vec4f.h.

◆ yz()

Vec yz ( ) const
constexpr

Definition at line 522 of file vec4f.h.

◆ yzw()

Vec yzw ( ) const
constexpr

Definition at line 658 of file vec4f.h.

◆ yzwx()

Vec yzwx ( ) const
constexpr

Definition at line 850 of file vec4f.h.

◆ yzx()

Vec yzx ( ) const
constexpr

Definition at line 650 of file vec4f.h.

◆ yzxw()

Vec yzxw ( ) const
constexpr

Definition at line 842 of file vec4f.h.

◆ ZAxis()

static GfVec4f ZAxis ( )
inlinestatic

Create a unit vector along the Z-axis.

Definition at line 114 of file vec4f.h.

◆ zw()

Vec zw ( ) const
constexpr

Definition at line 554 of file vec4f.h.

◆ zwx()

Vec zwx ( ) const
constexpr

Definition at line 714 of file vec4f.h.

◆ zwxy()

Vec zwxy ( ) const
constexpr

Definition at line 906 of file vec4f.h.

◆ zwy()

Vec zwy ( ) const
constexpr

Definition at line 722 of file vec4f.h.

◆ zwyx()

Vec zwyx ( ) const
constexpr

Definition at line 914 of file vec4f.h.

◆ zx()

Vec zx ( ) const
constexpr

Definition at line 538 of file vec4f.h.

◆ zxw()

Vec zxw ( ) const
constexpr

Definition at line 690 of file vec4f.h.

◆ zxwy()

Vec zxwy ( ) const
constexpr

Definition at line 882 of file vec4f.h.

◆ zxy()

Vec zxy ( ) const
constexpr

Definition at line 682 of file vec4f.h.

◆ zxyw()

Vec zxyw ( ) const
constexpr

Definition at line 874 of file vec4f.h.

◆ zy()

Vec zy ( ) const
constexpr

Definition at line 546 of file vec4f.h.

◆ zyw()

Vec zyw ( ) const
constexpr

Definition at line 706 of file vec4f.h.

◆ zywx()

Vec zywx ( ) const
constexpr

Definition at line 898 of file vec4f.h.

◆ zyx()

Vec zyx ( ) const
constexpr

Definition at line 698 of file vec4f.h.

◆ zyxw()

Vec zyxw ( ) const
constexpr

Definition at line 890 of file vec4f.h.

Friends And Related Symbol Documentation

◆ hash_value

size_t hash_value ( GfVec4f const & vec)
friend

Hash.

Definition at line 164 of file vec4f.h.

◆ operator*

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

Definition at line 230 of file vec4f.h.

◆ operator+

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

Definition at line 203 of file vec4f.h.

◆ operator-

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

Definition at line 215 of file vec4f.h.

Member Data Documentation

◆ dimension

const size_t dimension = 4
static

Definition at line 52 of file vec4f.h.

◆ w

float w

Definition at line 65 of file vec4f.h.

◆ x

float x

Definition at line 65 of file vec4f.h.

◆ y

float y

Definition at line 65 of file vec4f.h.

◆ z

float z

Definition at line 65 of file vec4f.h.


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