Loading...
Searching...
No Matches
GfVec4h Class Reference

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

#include <vec4h.h>

Public Types

typedef GfHalf ScalarType
 Scalar element type and dimension.
 

Public Member Functions

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

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

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

Static Public Member Functions

static GfVec4h XAxis ()
 Create a unit vector along the X-axis.
 
static GfVec4h YAxis ()
 Create a unit vector along the Y-axis.
 
static GfVec4h ZAxis ()
 Create a unit vector along the Z-axis.
 
static GfVec4h WAxis ()
 Create a unit vector along the W-axis.
 
static GfVec4h 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.

GfHalf x
 
GfHalf y
 
GfHalf z
 
GfHalf w
 

Static Public Attributes

static const size_t dimension = 4
 

Friends

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

Detailed Description

Basic type for a vector of 4 GfHalf components.

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

Definition at line 48 of file vec4h.h.

Member Typedef Documentation

◆ ScalarType

Scalar element type and dimension.

Definition at line 52 of file vec4h.h.

Constructor & Destructor Documentation

◆ GfVec4h() [1/7]

GfVec4h ( )
default

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

◆ GfVec4h() [2/7]

GfVec4h ( GfHalf value)
inlineexplicitconstexpr

Initialize all elements to a single value.

Definition at line 74 of file vec4h.h.

◆ GfVec4h() [3/7]

GfVec4h ( GfHalf s0,
GfHalf s1,
GfHalf s2,
GfHalf s3 )
inlineconstexpr

Initialize all elements with explicit arguments.

Definition at line 80 of file vec4h.h.

◆ GfVec4h() [4/7]

template<class Scl >
GfVec4h ( Scl const * p)
inlineexplicitconstexpr

Construct with pointer to values.

Definition at line 87 of file vec4h.h.

◆ GfVec4h() [5/7]

GfVec4h ( class GfVec4d const & other)
inlineexplicit

Construct from GfVec4d.

Definition at line 465 of file vec4h.h.

◆ GfVec4h() [6/7]

GfVec4h ( class GfVec4f const & other)
inlineexplicit

Construct from GfVec4f.

Definition at line 473 of file vec4h.h.

◆ GfVec4h() [7/7]

GfVec4h ( class GfVec4i const & other)
inline

Implicitly convert from GfVec4i.

Definition at line 481 of file vec4h.h.

Member Function Documentation

◆ Axis()

static GfVec4h 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 130 of file vec4h.h.

◆ data() [1/2]

GfHalf * data ( )
inline

Definition at line 157 of file vec4h.h.

◆ data() [2/2]

GfHalf 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 156 of file vec4h.h.

◆ GetArray()

GfHalf const * GetArray ( ) const
inline

Definition at line 158 of file vec4h.h.

◆ GetComplement()

GfVec4h GetComplement ( GfVec4h const & b) const
inline

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

That is:

*this - this->GetProjection(b)
GfVec4h GetProjection(GfVec4h const &v) const
Returns the projection of this onto v.
Definition vec4h.h:256

Definition at line 265 of file vec4h.h.

◆ GetLength()

GfHalf GetLength ( ) const
inline

Length.

Definition at line 275 of file vec4h.h.

◆ GetLengthSq()

GfHalf GetLengthSq ( ) const
inline

Squared length.

Definition at line 270 of file vec4h.h.

◆ GetNormalized()

GfVec4h GetNormalized ( GfHalf eps = 0.001) const
inline

Definition at line 295 of file vec4h.h.

◆ GetProjection()

GfVec4h GetProjection ( GfVec4h const & v) const
inline

Returns the projection of this onto v.

That is:

v * (*this * v)

Definition at line 256 of file vec4h.h.

◆ Normalize()

GfHalf Normalize ( GfHalf eps = 0.001)
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 287 of file vec4h.h.

◆ operator!=()

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

Definition at line 176 of file vec4h.h.

◆ operator*() [1/2]

GfVec4h operator* ( double s) const
inline

Definition at line 228 of file vec4h.h.

◆ operator*() [2/2]

GfHalf operator* ( GfVec4h const & v) const
inline

See GfDot().

Definition at line 248 of file vec4h.h.

◆ operator*=()

GfVec4h & operator*= ( double s)
inline

Multiplication by scalar.

Definition at line 221 of file vec4h.h.

◆ operator+=()

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

Addition.

Definition at line 197 of file vec4h.h.

◆ operator-()

GfVec4h operator- ( ) const
inline

Create a vec with negated elements.

Definition at line 192 of file vec4h.h.

◆ operator-=()

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

Subtraction.

Definition at line 209 of file vec4h.h.

◆ operator/()

GfVec4h operator/ ( double s) const
inline

Definition at line 243 of file vec4h.h.

◆ operator/=()

GfVec4h & operator/= ( double s)
inline

Division by scalar.

Definition at line 237 of file vec4h.h.

◆ operator==() [1/4]

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

Equality comparison.

◆ operator==() [2/4]

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

Equality comparison.

◆ operator==() [3/4]

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

Equality comparison.

◆ operator==() [4/4]

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

Equality comparison.

Definition at line 170 of file vec4h.h.

◆ operator[]() [1/2]

GfHalf & operator[] ( size_t i)
inline

Definition at line 162 of file vec4h.h.

◆ operator[]() [2/2]

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

Indexing.

Definition at line 161 of file vec4h.h.

◆ Set() [1/2]

GfVec4h & Set ( GfHalf const * a)
inline

Set all elements with a pointer to data.

Definition at line 147 of file vec4h.h.

◆ Set() [2/2]

GfVec4h & Set ( GfHalf s0,
GfHalf s1,
GfHalf s2,
GfHalf s3 )
inline

Set all elements with passed arguments.

Definition at line 138 of file vec4h.h.

◆ WAxis()

static GfVec4h WAxis ( )
inlinestatic

Create a unit vector along the W-axis.

Definition at line 122 of file vec4h.h.

◆ wx()

Vec wx ( ) const
constexpr

Definition at line 563 of file vec4h.h.

◆ wxy()

Vec wxy ( ) const
constexpr

Definition at line 731 of file vec4h.h.

◆ wxyz()

Vec wxyz ( ) const
constexpr

Definition at line 923 of file vec4h.h.

◆ wxz()

Vec wxz ( ) const
constexpr

Definition at line 739 of file vec4h.h.

◆ wxzy()

Vec wxzy ( ) const
constexpr

Definition at line 931 of file vec4h.h.

◆ wy()

Vec wy ( ) const
constexpr

Definition at line 571 of file vec4h.h.

◆ wyx()

Vec wyx ( ) const
constexpr

Definition at line 747 of file vec4h.h.

◆ wyxz()

Vec wyxz ( ) const
constexpr

Definition at line 939 of file vec4h.h.

◆ wyz()

Vec wyz ( ) const
constexpr

Definition at line 755 of file vec4h.h.

◆ wyzx()

Vec wyzx ( ) const
constexpr

Definition at line 947 of file vec4h.h.

◆ wz()

Vec wz ( ) const
constexpr

Definition at line 579 of file vec4h.h.

◆ wzx()

Vec wzx ( ) const
constexpr

Definition at line 763 of file vec4h.h.

◆ wzxy()

Vec wzxy ( ) const
constexpr

Definition at line 955 of file vec4h.h.

◆ wzy()

Vec wzy ( ) const
constexpr

Definition at line 771 of file vec4h.h.

◆ wzyx()

Vec wzyx ( ) const
constexpr

Definition at line 963 of file vec4h.h.

◆ XAxis()

static GfVec4h XAxis ( )
inlinestatic

Create a unit vector along the X-axis.

Definition at line 101 of file vec4h.h.

◆ xw()

Vec xw ( ) const
constexpr

Definition at line 507 of file vec4h.h.

◆ xwy()

Vec xwy ( ) const
constexpr

Definition at line 619 of file vec4h.h.

◆ xwyz()

Vec xwyz ( ) const
constexpr

Definition at line 811 of file vec4h.h.

◆ xwz()

Vec xwz ( ) const
constexpr

Definition at line 627 of file vec4h.h.

◆ xwzy()

Vec xwzy ( ) const
constexpr

Definition at line 819 of file vec4h.h.

◆ xy()

Vec xy ( ) const
constexpr

Definition at line 491 of file vec4h.h.

◆ xyw()

Vec xyw ( ) const
constexpr

Definition at line 595 of file vec4h.h.

◆ xywz()

Vec xywz ( ) const
constexpr

Definition at line 787 of file vec4h.h.

◆ xyz()

Vec xyz ( ) const
constexpr

Definition at line 587 of file vec4h.h.

◆ xyzw()

Vec xyzw ( ) const
constexpr

Definition at line 779 of file vec4h.h.

◆ xz()

Vec xz ( ) const
constexpr

Definition at line 499 of file vec4h.h.

◆ xzw()

Vec xzw ( ) const
constexpr

Definition at line 611 of file vec4h.h.

◆ xzwy()

Vec xzwy ( ) const
constexpr

Definition at line 803 of file vec4h.h.

◆ xzy()

Vec xzy ( ) const
constexpr

Definition at line 603 of file vec4h.h.

◆ xzyw()

Vec xzyw ( ) const
constexpr

Definition at line 795 of file vec4h.h.

◆ YAxis()

static GfVec4h YAxis ( )
inlinestatic

Create a unit vector along the Y-axis.

Definition at line 108 of file vec4h.h.

◆ yw()

Vec yw ( ) const
constexpr

Definition at line 531 of file vec4h.h.

◆ ywx()

Vec ywx ( ) const
constexpr

Definition at line 667 of file vec4h.h.

◆ ywxz()

Vec ywxz ( ) const
constexpr

Definition at line 859 of file vec4h.h.

◆ ywz()

Vec ywz ( ) const
constexpr

Definition at line 675 of file vec4h.h.

◆ ywzx()

Vec ywzx ( ) const
constexpr

Definition at line 867 of file vec4h.h.

◆ yx()

Vec yx ( ) const
constexpr

Definition at line 515 of file vec4h.h.

◆ yxw()

Vec yxw ( ) const
constexpr

Definition at line 643 of file vec4h.h.

◆ yxwz()

Vec yxwz ( ) const
constexpr

Definition at line 835 of file vec4h.h.

◆ yxz()

Vec yxz ( ) const
constexpr

Definition at line 635 of file vec4h.h.

◆ yxzw()

Vec yxzw ( ) const
constexpr

Definition at line 827 of file vec4h.h.

◆ yz()

Vec yz ( ) const
constexpr

Definition at line 523 of file vec4h.h.

◆ yzw()

Vec yzw ( ) const
constexpr

Definition at line 659 of file vec4h.h.

◆ yzwx()

Vec yzwx ( ) const
constexpr

Definition at line 851 of file vec4h.h.

◆ yzx()

Vec yzx ( ) const
constexpr

Definition at line 651 of file vec4h.h.

◆ yzxw()

Vec yzxw ( ) const
constexpr

Definition at line 843 of file vec4h.h.

◆ ZAxis()

static GfVec4h ZAxis ( )
inlinestatic

Create a unit vector along the Z-axis.

Definition at line 115 of file vec4h.h.

◆ zw()

Vec zw ( ) const
constexpr

Definition at line 555 of file vec4h.h.

◆ zwx()

Vec zwx ( ) const
constexpr

Definition at line 715 of file vec4h.h.

◆ zwxy()

Vec zwxy ( ) const
constexpr

Definition at line 907 of file vec4h.h.

◆ zwy()

Vec zwy ( ) const
constexpr

Definition at line 723 of file vec4h.h.

◆ zwyx()

Vec zwyx ( ) const
constexpr

Definition at line 915 of file vec4h.h.

◆ zx()

Vec zx ( ) const
constexpr

Definition at line 539 of file vec4h.h.

◆ zxw()

Vec zxw ( ) const
constexpr

Definition at line 691 of file vec4h.h.

◆ zxwy()

Vec zxwy ( ) const
constexpr

Definition at line 883 of file vec4h.h.

◆ zxy()

Vec zxy ( ) const
constexpr

Definition at line 683 of file vec4h.h.

◆ zxyw()

Vec zxyw ( ) const
constexpr

Definition at line 875 of file vec4h.h.

◆ zy()

Vec zy ( ) const
constexpr

Definition at line 547 of file vec4h.h.

◆ zyw()

Vec zyw ( ) const
constexpr

Definition at line 707 of file vec4h.h.

◆ zywx()

Vec zywx ( ) const
constexpr

Definition at line 899 of file vec4h.h.

◆ zyx()

Vec zyx ( ) const
constexpr

Definition at line 699 of file vec4h.h.

◆ zyxw()

Vec zyxw ( ) const
constexpr

Definition at line 891 of file vec4h.h.

Friends And Related Symbol Documentation

◆ hash_value

size_t hash_value ( GfVec4h const & vec)
friend

Hash.

Definition at line 165 of file vec4h.h.

◆ operator*

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

Definition at line 231 of file vec4h.h.

◆ operator+

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

Definition at line 204 of file vec4h.h.

◆ operator-

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

Definition at line 216 of file vec4h.h.

Member Data Documentation

◆ dimension

const size_t dimension = 4
static

Definition at line 53 of file vec4h.h.

◆ w

GfHalf w

Definition at line 66 of file vec4h.h.

◆ x

GfHalf x

Definition at line 66 of file vec4h.h.

◆ y

GfHalf y

Definition at line 66 of file vec4h.h.

◆ z

GfHalf z

Definition at line 66 of file vec4h.h.


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