Loading...
Searching...
No Matches
GfVec4d Class Reference

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

#include <vec4d.h>

Public Types

typedef double ScalarType
 Scalar element type and dimension.
 

Public Member Functions

 GfVec4d ()=default
 GfVec4d value-initializes to zero and performs no default initialization, like float or double.
 
constexpr GfVec4d (double value)
 Initialize all elements to a single value.
 
constexpr GfVec4d (double s0, double s1, double s2, double s3)
 Initialize all elements with explicit arguments.
 
template<class Scl >
constexpr GfVec4d (Scl const *p)
 Construct with pointer to values.
 
 GfVec4d (class GfVec4f const &other)
 Implicitly convert from GfVec4f.
 
 GfVec4d (class GfVec4h const &other)
 Implicitly convert from GfVec4h.
 
 GfVec4d (class GfVec4i const &other)
 Implicitly convert from GfVec4i.
 
GfVec4dSet (double s0, double s1, double s2, double s3)
 Set all elements with passed arguments.
 
GfVec4dSet (double const *a)
 Set all elements with a pointer to data.
 
double const * data () const
 Direct data access.
 
double * data ()
 
double const * GetArray () const
 
double const & operator[] (size_t i) const
 Indexing.
 
double & operator[] (size_t i)
 
bool operator== (GfVec4d const &other) const
 Equality comparison.
 
bool operator!= (GfVec4d const &other) const
 
GF_API bool operator== (class GfVec4f 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.
 
GfVec4d operator- () const
 Create a vec with negated elements.
 
GfVec4doperator+= (GfVec4d const &other)
 Addition.
 
GfVec4doperator-= (GfVec4d const &other)
 Subtraction.
 
GfVec4doperator*= (double s)
 Multiplication by scalar.
 
GfVec4d operator* (double s) const
 
GfVec4doperator/= (double s)
 Division by scalar.
 
GfVec4d operator/ (double s) const
 
double operator* (GfVec4d const &v) const
 See GfDot().
 
GfVec4d GetProjection (GfVec4d const &v) const
 Returns the projection of this onto v.
 
GfVec4d GetComplement (GfVec4d const &b) const
 Returns the orthogonal complement of this->GetProjection(b).
 
double GetLengthSq () const
 Squared length.
 
double GetLength () const
 Length.
 
double Normalize (double eps=GF_MIN_VECTOR_LENGTH)
 Normalizes the vector in place to unit length, returning the length before normalization.
 
GfVec4d GetNormalized (double 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 GfVec4d(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 GfVec2d xy () const
 
constexpr GfVec2d xz () const
 
constexpr GfVec2d xw () const
 
constexpr GfVec2d yx () const
 
constexpr GfVec2d yz () const
 
constexpr GfVec2d yw () const
 
constexpr GfVec2d zx () const
 
constexpr GfVec2d zy () const
 
constexpr GfVec2d zw () const
 
constexpr GfVec2d wx () const
 
constexpr GfVec2d wy () const
 
constexpr GfVec2d wz () const
 
constexpr GfVec3d xyz () const
 
constexpr GfVec3d xyw () const
 
constexpr GfVec3d xzy () const
 
constexpr GfVec3d xzw () const
 
constexpr GfVec3d xwy () const
 
constexpr GfVec3d xwz () const
 
constexpr GfVec3d yxz () const
 
constexpr GfVec3d yxw () const
 
constexpr GfVec3d yzx () const
 
constexpr GfVec3d yzw () const
 
constexpr GfVec3d ywx () const
 
constexpr GfVec3d ywz () const
 
constexpr GfVec3d zxy () const
 
constexpr GfVec3d zxw () const
 
constexpr GfVec3d zyx () const
 
constexpr GfVec3d zyw () const
 
constexpr GfVec3d zwx () const
 
constexpr GfVec3d zwy () const
 
constexpr GfVec3d wxy () const
 
constexpr GfVec3d wxz () const
 
constexpr GfVec3d wyx () const
 
constexpr GfVec3d wyz () const
 
constexpr GfVec3d wzx () const
 
constexpr GfVec3d wzy () const
 
constexpr GfVec4d xyzw () const
 
constexpr GfVec4d xywz () const
 
constexpr GfVec4d xzyw () const
 
constexpr GfVec4d xzwy () const
 
constexpr GfVec4d xwyz () const
 
constexpr GfVec4d xwzy () const
 
constexpr GfVec4d yxzw () const
 
constexpr GfVec4d yxwz () const
 
constexpr GfVec4d yzxw () const
 
constexpr GfVec4d yzwx () const
 
constexpr GfVec4d ywxz () const
 
constexpr GfVec4d ywzx () const
 
constexpr GfVec4d zxyw () const
 
constexpr GfVec4d zxwy () const
 
constexpr GfVec4d zyxw () const
 
constexpr GfVec4d zywx () const
 
constexpr GfVec4d zwxy () const
 
constexpr GfVec4d zwyx () const
 
constexpr GfVec4d wxyz () const
 
constexpr GfVec4d wxzy () const
 
constexpr GfVec4d wyxz () const
 
constexpr GfVec4d wyzx () const
 
constexpr GfVec4d wzxy () const
 
constexpr GfVec4d wzyx () const
 

Static Public Member Functions

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

double x
 
double y
 
double z
 
double w
 

Static Public Attributes

static const size_t dimension = 4
 

Friends

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

Detailed Description

Basic type for a vector of 4 double components.

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

Definition at line 47 of file vec4d.h.

Member Typedef Documentation

◆ ScalarType

double ScalarType

Scalar element type and dimension.

Definition at line 51 of file vec4d.h.

Constructor & Destructor Documentation

◆ GfVec4d() [1/7]

GfVec4d ( )
default

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

◆ GfVec4d() [2/7]

GfVec4d ( double value)
inlineexplicitconstexpr

Initialize all elements to a single value.

Definition at line 73 of file vec4d.h.

◆ GfVec4d() [3/7]

GfVec4d ( double s0,
double s1,
double s2,
double s3 )
inlineconstexpr

Initialize all elements with explicit arguments.

Definition at line 79 of file vec4d.h.

◆ GfVec4d() [4/7]

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

Construct with pointer to values.

Definition at line 86 of file vec4d.h.

◆ GfVec4d() [5/7]

GfVec4d ( class GfVec4f const & other)
inline

Implicitly convert from GfVec4f.

Definition at line 464 of file vec4d.h.

◆ GfVec4d() [6/7]

GfVec4d ( class GfVec4h const & other)
inline

Implicitly convert from GfVec4h.

Definition at line 472 of file vec4d.h.

◆ GfVec4d() [7/7]

GfVec4d ( class GfVec4i const & other)
inline

Implicitly convert from GfVec4i.

Definition at line 480 of file vec4d.h.

Member Function Documentation

◆ Axis()

static GfVec4d 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 vec4d.h.

◆ data() [1/2]

double * data ( )
inline

Definition at line 156 of file vec4d.h.

◆ data() [2/2]

double 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 vec4d.h.

◆ GetArray()

double const * GetArray ( ) const
inline

Definition at line 157 of file vec4d.h.

◆ GetComplement()

GfVec4d GetComplement ( GfVec4d const & b) const
inline

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

That is:

*this - this->GetProjection(b)
GfVec4d GetProjection(GfVec4d const &v) const
Returns the projection of this onto v.
Definition vec4d.h:255

Definition at line 264 of file vec4d.h.

◆ GetLength()

double GetLength ( ) const
inline

Length.

Definition at line 274 of file vec4d.h.

◆ GetLengthSq()

double GetLengthSq ( ) const
inline

Squared length.

Definition at line 269 of file vec4d.h.

◆ GetNormalized()

GfVec4d GetNormalized ( double eps = GF_MIN_VECTOR_LENGTH) const
inline

Definition at line 294 of file vec4d.h.

◆ GetProjection()

GfVec4d GetProjection ( GfVec4d const & v) const
inline

Returns the projection of this onto v.

That is:

v * (*this * v)

Definition at line 255 of file vec4d.h.

◆ Normalize()

double Normalize ( double 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 vec4d.h.

◆ operator!=()

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

Definition at line 175 of file vec4d.h.

◆ operator*() [1/2]

GfVec4d operator* ( double s) const
inline

Definition at line 227 of file vec4d.h.

◆ operator*() [2/2]

double operator* ( GfVec4d const & v) const
inline

See GfDot().

Definition at line 247 of file vec4d.h.

◆ operator*=()

GfVec4d & operator*= ( double s)
inline

Multiplication by scalar.

Definition at line 220 of file vec4d.h.

◆ operator+=()

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

Addition.

Definition at line 196 of file vec4d.h.

◆ operator-()

GfVec4d operator- ( ) const
inline

Create a vec with negated elements.

Definition at line 191 of file vec4d.h.

◆ operator-=()

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

Subtraction.

Definition at line 208 of file vec4d.h.

◆ operator/()

GfVec4d operator/ ( double s) const
inline

Definition at line 242 of file vec4d.h.

◆ operator/=()

GfVec4d & operator/= ( double s)
inline

Division by scalar.

Definition at line 236 of file vec4d.h.

◆ operator==() [1/4]

GF_API bool operator== ( class GfVec4f 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== ( GfVec4d const & other) const
inline

Equality comparison.

Definition at line 169 of file vec4d.h.

◆ operator[]() [1/2]

double & operator[] ( size_t i)
inline

Definition at line 161 of file vec4d.h.

◆ operator[]() [2/2]

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

Indexing.

Definition at line 160 of file vec4d.h.

◆ Set() [1/2]

GfVec4d & Set ( double const * a)
inline

Set all elements with a pointer to data.

Definition at line 146 of file vec4d.h.

◆ Set() [2/2]

GfVec4d & Set ( double s0,
double s1,
double s2,
double s3 )
inline

Set all elements with passed arguments.

Definition at line 137 of file vec4d.h.

◆ WAxis()

static GfVec4d WAxis ( )
inlinestatic

Create a unit vector along the W-axis.

Definition at line 121 of file vec4d.h.

◆ wx()

Vec wx ( ) const
constexpr

Definition at line 562 of file vec4d.h.

◆ wxy()

Vec wxy ( ) const
constexpr

Definition at line 730 of file vec4d.h.

◆ wxyz()

Vec wxyz ( ) const
constexpr

Definition at line 922 of file vec4d.h.

◆ wxz()

Vec wxz ( ) const
constexpr

Definition at line 738 of file vec4d.h.

◆ wxzy()

Vec wxzy ( ) const
constexpr

Definition at line 930 of file vec4d.h.

◆ wy()

Vec wy ( ) const
constexpr

Definition at line 570 of file vec4d.h.

◆ wyx()

Vec wyx ( ) const
constexpr

Definition at line 746 of file vec4d.h.

◆ wyxz()

Vec wyxz ( ) const
constexpr

Definition at line 938 of file vec4d.h.

◆ wyz()

Vec wyz ( ) const
constexpr

Definition at line 754 of file vec4d.h.

◆ wyzx()

Vec wyzx ( ) const
constexpr

Definition at line 946 of file vec4d.h.

◆ wz()

Vec wz ( ) const
constexpr

Definition at line 578 of file vec4d.h.

◆ wzx()

Vec wzx ( ) const
constexpr

Definition at line 762 of file vec4d.h.

◆ wzxy()

Vec wzxy ( ) const
constexpr

Definition at line 954 of file vec4d.h.

◆ wzy()

Vec wzy ( ) const
constexpr

Definition at line 770 of file vec4d.h.

◆ wzyx()

Vec wzyx ( ) const
constexpr

Definition at line 962 of file vec4d.h.

◆ XAxis()

static GfVec4d XAxis ( )
inlinestatic

Create a unit vector along the X-axis.

Definition at line 100 of file vec4d.h.

◆ xw()

Vec xw ( ) const
constexpr

Definition at line 506 of file vec4d.h.

◆ xwy()

Vec xwy ( ) const
constexpr

Definition at line 618 of file vec4d.h.

◆ xwyz()

Vec xwyz ( ) const
constexpr

Definition at line 810 of file vec4d.h.

◆ xwz()

Vec xwz ( ) const
constexpr

Definition at line 626 of file vec4d.h.

◆ xwzy()

Vec xwzy ( ) const
constexpr

Definition at line 818 of file vec4d.h.

◆ xy()

Vec xy ( ) const
constexpr

Definition at line 490 of file vec4d.h.

◆ xyw()

Vec xyw ( ) const
constexpr

Definition at line 594 of file vec4d.h.

◆ xywz()

Vec xywz ( ) const
constexpr

Definition at line 786 of file vec4d.h.

◆ xyz()

Vec xyz ( ) const
constexpr

Definition at line 586 of file vec4d.h.

◆ xyzw()

Vec xyzw ( ) const
constexpr

Definition at line 778 of file vec4d.h.

◆ xz()

Vec xz ( ) const
constexpr

Definition at line 498 of file vec4d.h.

◆ xzw()

Vec xzw ( ) const
constexpr

Definition at line 610 of file vec4d.h.

◆ xzwy()

Vec xzwy ( ) const
constexpr

Definition at line 802 of file vec4d.h.

◆ xzy()

Vec xzy ( ) const
constexpr

Definition at line 602 of file vec4d.h.

◆ xzyw()

Vec xzyw ( ) const
constexpr

Definition at line 794 of file vec4d.h.

◆ YAxis()

static GfVec4d YAxis ( )
inlinestatic

Create a unit vector along the Y-axis.

Definition at line 107 of file vec4d.h.

◆ yw()

Vec yw ( ) const
constexpr

Definition at line 530 of file vec4d.h.

◆ ywx()

Vec ywx ( ) const
constexpr

Definition at line 666 of file vec4d.h.

◆ ywxz()

Vec ywxz ( ) const
constexpr

Definition at line 858 of file vec4d.h.

◆ ywz()

Vec ywz ( ) const
constexpr

Definition at line 674 of file vec4d.h.

◆ ywzx()

Vec ywzx ( ) const
constexpr

Definition at line 866 of file vec4d.h.

◆ yx()

Vec yx ( ) const
constexpr

Definition at line 514 of file vec4d.h.

◆ yxw()

Vec yxw ( ) const
constexpr

Definition at line 642 of file vec4d.h.

◆ yxwz()

Vec yxwz ( ) const
constexpr

Definition at line 834 of file vec4d.h.

◆ yxz()

Vec yxz ( ) const
constexpr

Definition at line 634 of file vec4d.h.

◆ yxzw()

Vec yxzw ( ) const
constexpr

Definition at line 826 of file vec4d.h.

◆ yz()

Vec yz ( ) const
constexpr

Definition at line 522 of file vec4d.h.

◆ yzw()

Vec yzw ( ) const
constexpr

Definition at line 658 of file vec4d.h.

◆ yzwx()

Vec yzwx ( ) const
constexpr

Definition at line 850 of file vec4d.h.

◆ yzx()

Vec yzx ( ) const
constexpr

Definition at line 650 of file vec4d.h.

◆ yzxw()

Vec yzxw ( ) const
constexpr

Definition at line 842 of file vec4d.h.

◆ ZAxis()

static GfVec4d ZAxis ( )
inlinestatic

Create a unit vector along the Z-axis.

Definition at line 114 of file vec4d.h.

◆ zw()

Vec zw ( ) const
constexpr

Definition at line 554 of file vec4d.h.

◆ zwx()

Vec zwx ( ) const
constexpr

Definition at line 714 of file vec4d.h.

◆ zwxy()

Vec zwxy ( ) const
constexpr

Definition at line 906 of file vec4d.h.

◆ zwy()

Vec zwy ( ) const
constexpr

Definition at line 722 of file vec4d.h.

◆ zwyx()

Vec zwyx ( ) const
constexpr

Definition at line 914 of file vec4d.h.

◆ zx()

Vec zx ( ) const
constexpr

Definition at line 538 of file vec4d.h.

◆ zxw()

Vec zxw ( ) const
constexpr

Definition at line 690 of file vec4d.h.

◆ zxwy()

Vec zxwy ( ) const
constexpr

Definition at line 882 of file vec4d.h.

◆ zxy()

Vec zxy ( ) const
constexpr

Definition at line 682 of file vec4d.h.

◆ zxyw()

Vec zxyw ( ) const
constexpr

Definition at line 874 of file vec4d.h.

◆ zy()

Vec zy ( ) const
constexpr

Definition at line 546 of file vec4d.h.

◆ zyw()

Vec zyw ( ) const
constexpr

Definition at line 706 of file vec4d.h.

◆ zywx()

Vec zywx ( ) const
constexpr

Definition at line 898 of file vec4d.h.

◆ zyx()

Vec zyx ( ) const
constexpr

Definition at line 698 of file vec4d.h.

◆ zyxw()

Vec zyxw ( ) const
constexpr

Definition at line 890 of file vec4d.h.

Friends And Related Symbol Documentation

◆ hash_value

size_t hash_value ( GfVec4d const & vec)
friend

Hash.

Definition at line 164 of file vec4d.h.

◆ operator*

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

Definition at line 230 of file vec4d.h.

◆ operator+

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

Definition at line 203 of file vec4d.h.

◆ operator-

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

Definition at line 215 of file vec4d.h.

Member Data Documentation

◆ dimension

const size_t dimension = 4
static

Definition at line 52 of file vec4d.h.

◆ w

double w

Definition at line 65 of file vec4d.h.

◆ x

double x

Definition at line 65 of file vec4d.h.

◆ y

double y

Definition at line 65 of file vec4d.h.

◆ z

double z

Definition at line 65 of file vec4d.h.


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