Loading...
Searching...
No Matches
GfVec3h Class Reference

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

#include <vec3h.h>

Public Types

typedef GfHalf ScalarType
 Scalar element type and dimension.
 

Public Member Functions

 GfVec3h ()=default
 GfVec3h value-initializes to zero and performs no default initialization, like float or double.
 
constexpr GfVec3h (GfHalf value)
 Initialize all elements to a single value.
 
constexpr GfVec3h (GfHalf s0, GfHalf s1, GfHalf s2)
 Initialize all elements with explicit arguments.
 
template<class Scl >
constexpr GfVec3h (Scl const *p)
 Construct with pointer to values.
 
 GfVec3h (class GfVec3d const &other)
 Construct from GfVec3d.
 
 GfVec3h (class GfVec3f const &other)
 Construct from GfVec3f.
 
 GfVec3h (class GfVec3i const &other)
 Implicitly convert from GfVec3i.
 
GfVec3hSet (GfHalf s0, GfHalf s1, GfHalf s2)
 Set all elements with passed arguments.
 
GfVec3hSet (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== (GfVec3h const &other) const
 Equality comparison.
 
bool operator!= (GfVec3h const &other) const
 
GF_API bool operator== (class GfVec3d const &other) const
 Equality comparison.
 
GF_API bool operator== (class GfVec3f const &other) const
 Equality comparison.
 
GF_API bool operator== (class GfVec3i const &other) const
 Equality comparison.
 
GfVec3h operator- () const
 Create a vec with negated elements.
 
GfVec3hoperator+= (GfVec3h const &other)
 Addition.
 
GfVec3hoperator-= (GfVec3h const &other)
 Subtraction.
 
GfVec3hoperator*= (double s)
 Multiplication by scalar.
 
GfVec3h operator* (double s) const
 
GfVec3hoperator/= (double s)
 Division by scalar.
 
GfVec3h operator/ (double s) const
 
GfHalf operator* (GfVec3h const &v) const
 See GfDot().
 
GfVec3h GetProjection (GfVec3h const &v) const
 Returns the projection of this onto v.
 
GfVec3h GetComplement (GfVec3h 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.
 
GfVec3h GetNormalized (GfHalf eps=0.001) const
 
GF_API void BuildOrthonormalFrame (GfVec3h *v1, GfVec3h *v2, GfHalf eps=0.001) const
 Sets v1 and v2 to unit vectors such that v1, v2 and *this are mutually orthogonal.
 
Swizzles

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

For example zyx() returns GfVec3h(z, y, x).

Every permutation of 2 to 3 of the 3 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 yx () const
 
constexpr GfVec2h yz () const
 
constexpr GfVec2h zx () const
 
constexpr GfVec2h zy () const
 
constexpr GfVec3h xyz () const
 
constexpr GfVec3h xzy () const
 
constexpr GfVec3h yxz () const
 
constexpr GfVec3h yzx () const
 
constexpr GfVec3h zxy () const
 
constexpr GfVec3h zyx () const
 

Static Public Member Functions

static GfVec3h XAxis ()
 Create a unit vector along the X-axis.
 
static GfVec3h YAxis ()
 Create a unit vector along the Y-axis.
 
static GfVec3h ZAxis ()
 Create a unit vector along the Z-axis.
 
static GfVec3h Axis (size_t i)
 Create a unit vector along the i-th axis, zero-based.
 
static GF_API bool OrthogonalizeBasis (GfVec3h *tx, GfVec3h *ty, GfVec3h *tz, const bool normalize, double eps=GF_MIN_ORTHO_TOLERANCE)
 Orthogonalize and optionally normalize a set of basis vectors.
 

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
 

Static Public Attributes

static const size_t dimension = 3
 

Friends

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

Detailed Description

Basic type for a vector of 3 GfHalf components.

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

Definition at line 47 of file vec3h.h.

Member Typedef Documentation

◆ ScalarType

Scalar element type and dimension.

Definition at line 51 of file vec3h.h.

Constructor & Destructor Documentation

◆ GfVec3h() [1/7]

GfVec3h ( )
default

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

◆ GfVec3h() [2/7]

GfVec3h ( GfHalf value)
inlineexplicitconstexpr

Initialize all elements to a single value.

Definition at line 73 of file vec3h.h.

◆ GfVec3h() [3/7]

GfVec3h ( GfHalf s0,
GfHalf s1,
GfHalf s2 )
inlineconstexpr

Initialize all elements with explicit arguments.

Definition at line 79 of file vec3h.h.

◆ GfVec3h() [4/7]

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

Construct with pointer to values.

Definition at line 86 of file vec3h.h.

◆ GfVec3h() [5/7]

GfVec3h ( class GfVec3d const & other)
inlineexplicit

Construct from GfVec3d.

Definition at line 378 of file vec3h.h.

◆ GfVec3h() [6/7]

GfVec3h ( class GfVec3f const & other)
inlineexplicit

Construct from GfVec3f.

Definition at line 385 of file vec3h.h.

◆ GfVec3h() [7/7]

GfVec3h ( class GfVec3i const & other)
inline

Implicitly convert from GfVec3i.

Definition at line 392 of file vec3h.h.

Member Function Documentation

◆ Axis()

static GfVec3h 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 3.

Definition at line 122 of file vec3h.h.

◆ BuildOrthonormalFrame()

GF_API void BuildOrthonormalFrame ( GfVec3h * v1,
GfVec3h * v2,
GfHalf eps = 0.001 ) const

Sets v1 and v2 to unit vectors such that v1, v2 and *this are mutually orthogonal.

If the length L of *this is smaller than eps, then v1 and v2 will have magnitude L/eps. As a result, the function delivers a continuous result as *this shrinks in length.

◆ data() [1/2]

GfHalf * data ( )
inline

Definition at line 148 of file vec3h.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 147 of file vec3h.h.

◆ GetArray()

GfHalf const * GetArray ( ) const
inline

Definition at line 149 of file vec3h.h.

◆ GetComplement()

GfVec3h GetComplement ( GfVec3h const & b) const
inline

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

That is:

*this - this->GetProjection(b)
GfVec3h GetProjection(GfVec3h const &v) const
Returns the projection of this onto v.
Definition vec3h.h:243

Definition at line 252 of file vec3h.h.

◆ GetLength()

GfHalf GetLength ( ) const
inline

Length.

Definition at line 262 of file vec3h.h.

◆ GetLengthSq()

GfHalf GetLengthSq ( ) const
inline

Squared length.

Definition at line 257 of file vec3h.h.

◆ GetNormalized()

GfVec3h GetNormalized ( GfHalf eps = 0.001) const
inline

Definition at line 282 of file vec3h.h.

◆ GetProjection()

GfVec3h GetProjection ( GfVec3h const & v) const
inline

Returns the projection of this onto v.

That is:

v * (*this * v)

Definition at line 243 of file vec3h.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 274 of file vec3h.h.

◆ operator!=()

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

Definition at line 166 of file vec3h.h.

◆ operator*() [1/2]

GfVec3h operator* ( double s) const
inline

Definition at line 215 of file vec3h.h.

◆ operator*() [2/2]

GfHalf operator* ( GfVec3h const & v) const
inline

See GfDot().

Definition at line 235 of file vec3h.h.

◆ operator*=()

GfVec3h & operator*= ( double s)
inline

Multiplication by scalar.

Definition at line 209 of file vec3h.h.

◆ operator+=()

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

Addition.

Definition at line 187 of file vec3h.h.

◆ operator-()

GfVec3h operator- ( ) const
inline

Create a vec with negated elements.

Definition at line 182 of file vec3h.h.

◆ operator-=()

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

Subtraction.

Definition at line 198 of file vec3h.h.

◆ operator/()

GfVec3h operator/ ( double s) const
inline

Definition at line 230 of file vec3h.h.

◆ operator/=()

GfVec3h & operator/= ( double s)
inline

Division by scalar.

Definition at line 224 of file vec3h.h.

◆ operator==() [1/4]

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

Equality comparison.

◆ operator==() [2/4]

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

Equality comparison.

◆ operator==() [3/4]

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

Equality comparison.

◆ operator==() [4/4]

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

Equality comparison.

Definition at line 161 of file vec3h.h.

◆ operator[]() [1/2]

GfHalf & operator[] ( size_t i)
inline

Definition at line 153 of file vec3h.h.

◆ operator[]() [2/2]

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

Indexing.

Definition at line 152 of file vec3h.h.

◆ OrthogonalizeBasis()

static GF_API bool OrthogonalizeBasis ( GfVec3h * tx,
GfVec3h * ty,
GfVec3h * tz,
const bool normalize,
double eps = GF_MIN_ORTHO_TOLERANCE )
static

Orthogonalize and optionally normalize a set of basis vectors.

This uses an iterative method that is very stable even when the vectors are far from orthogonal (close to colinear). The number of iterations and thus the computation time does increase as the vectors become close to colinear, however. Returns a bool specifying whether the solution converged after a number of iterations. If it did not converge, the returned vectors will be as close as possible to orthogonal within the iteration limit. Colinear vectors will be unaltered, and the method will return false.

◆ Set() [1/2]

GfVec3h & Set ( GfHalf const * a)
inline

Set all elements with a pointer to data.

Definition at line 138 of file vec3h.h.

◆ Set() [2/2]

GfVec3h & Set ( GfHalf s0,
GfHalf s1,
GfHalf s2 )
inline

Set all elements with passed arguments.

Definition at line 130 of file vec3h.h.

◆ XAxis()

static GfVec3h XAxis ( )
inlinestatic

Create a unit vector along the X-axis.

Definition at line 100 of file vec3h.h.

◆ xy()

Vec xy ( ) const
constexpr

Definition at line 401 of file vec3h.h.

◆ xyz()

Vec xyz ( ) const
constexpr

Definition at line 449 of file vec3h.h.

◆ xz()

Vec xz ( ) const
constexpr

Definition at line 409 of file vec3h.h.

◆ xzy()

Vec xzy ( ) const
constexpr

Definition at line 457 of file vec3h.h.

◆ YAxis()

static GfVec3h YAxis ( )
inlinestatic

Create a unit vector along the Y-axis.

Definition at line 107 of file vec3h.h.

◆ yx()

Vec yx ( ) const
constexpr

Definition at line 417 of file vec3h.h.

◆ yxz()

Vec yxz ( ) const
constexpr

Definition at line 465 of file vec3h.h.

◆ yz()

Vec yz ( ) const
constexpr

Definition at line 425 of file vec3h.h.

◆ yzx()

Vec yzx ( ) const
constexpr

Definition at line 473 of file vec3h.h.

◆ ZAxis()

static GfVec3h ZAxis ( )
inlinestatic

Create a unit vector along the Z-axis.

Definition at line 114 of file vec3h.h.

◆ zx()

Vec zx ( ) const
constexpr

Definition at line 433 of file vec3h.h.

◆ zxy()

Vec zxy ( ) const
constexpr

Definition at line 481 of file vec3h.h.

◆ zy()

Vec zy ( ) const
constexpr

Definition at line 441 of file vec3h.h.

◆ zyx()

Vec zyx ( ) const
constexpr

Definition at line 489 of file vec3h.h.

Friends And Related Symbol Documentation

◆ hash_value

size_t hash_value ( GfVec3h const & vec)
friend

Hash.

Definition at line 156 of file vec3h.h.

◆ operator*

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

Definition at line 218 of file vec3h.h.

◆ operator+

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

Definition at line 193 of file vec3h.h.

◆ operator-

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

Definition at line 204 of file vec3h.h.

Member Data Documentation

◆ dimension

const size_t dimension = 3
static

Definition at line 52 of file vec3h.h.

◆ x

GfHalf x

Definition at line 65 of file vec3h.h.

◆ y

GfHalf y

Definition at line 65 of file vec3h.h.

◆ z

GfHalf z

Definition at line 65 of file vec3h.h.


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