Loading...
Searching...
No Matches
GfVec3d Class Reference

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

#include <vec3d.h>

Public Types

typedef double ScalarType
 Scalar element type and dimension.
 

Public Member Functions

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

Static Public Member Functions

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

Static Public Attributes

static const size_t dimension = 3
 

Friends

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

Detailed Description

Basic type for a vector of 3 double components.

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

Definition at line 45 of file vec3d.h.

Member Typedef Documentation

◆ ScalarType

typedef double ScalarType

Scalar element type and dimension.

Definition at line 49 of file vec3d.h.

Constructor & Destructor Documentation

◆ GfVec3d() [1/7]

GfVec3d ( )
default

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

◆ GfVec3d() [2/7]

constexpr GfVec3d ( double  value)
inlineexplicitconstexpr

Initialize all elements to a single value.

Definition at line 57 of file vec3d.h.

◆ GfVec3d() [3/7]

constexpr GfVec3d ( double  s0,
double  s1,
double  s2 
)
inlineconstexpr

Initialize all elements with explicit arguments.

Definition at line 63 of file vec3d.h.

◆ GfVec3d() [4/7]

constexpr GfVec3d ( Scl const *  p)
inlineexplicitconstexpr

Construct with pointer to values.

Definition at line 70 of file vec3d.h.

◆ GfVec3d() [5/7]

GfVec3d ( class GfVec3f const &  other)
inline

Implicitly convert from GfVec3f.

Definition at line 309 of file vec3d.h.

◆ GfVec3d() [6/7]

GfVec3d ( class GfVec3h const &  other)
inline

Implicitly convert from GfVec3h.

Definition at line 316 of file vec3d.h.

◆ GfVec3d() [7/7]

GfVec3d ( class GfVec3i const &  other)
inline

Implicitly convert from GfVec3i.

Definition at line 323 of file vec3d.h.

Member Function Documentation

◆ Axis()

static GfVec3d 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 105 of file vec3d.h.

◆ BuildOrthonormalFrame()

GF_API void BuildOrthonormalFrame ( GfVec3d v1,
GfVec3d v2,
double  eps = GF_MIN_VECTOR_LENGTH 
) 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]

double * data ( )
inline

Definition at line 127 of file vec3d.h.

◆ data() [2/2]

double const * data ( ) const
inline

Direct data access.

Definition at line 126 of file vec3d.h.

◆ GetArray()

double const * GetArray ( ) const
inline

Definition at line 128 of file vec3d.h.

◆ GetComplement()

GfVec3d GetComplement ( GfVec3d const &  b) const
inline

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

That is:

*this - this->GetProjection(b)
GfVec3d GetProjection(GfVec3d const &v) const
Returns the projection of this onto v.
Definition: vec3d.h:222

Definition at line 231 of file vec3d.h.

◆ GetLength()

double GetLength ( ) const
inline

Length.

Definition at line 241 of file vec3d.h.

◆ GetLengthSq()

double GetLengthSq ( ) const
inline

Squared length.

Definition at line 236 of file vec3d.h.

◆ GetNormalized()

GfVec3d GetNormalized ( double  eps = GF_MIN_VECTOR_LENGTH) const
inline

Definition at line 261 of file vec3d.h.

◆ GetProjection()

GfVec3d GetProjection ( GfVec3d const &  v) const
inline

Returns the projection of this onto v.

That is:

v * (*this * v)

Definition at line 222 of file vec3d.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 253 of file vec3d.h.

◆ operator!=()

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

Definition at line 145 of file vec3d.h.

◆ operator*() [1/2]

GfVec3d operator* ( double  s) const
inline

Definition at line 194 of file vec3d.h.

◆ operator*() [2/2]

double operator* ( GfVec3d const &  v) const
inline

See GfDot().

Definition at line 214 of file vec3d.h.

◆ operator*=()

GfVec3d & operator*= ( double  s)
inline

Multiplication by scalar.

Definition at line 188 of file vec3d.h.

◆ operator+=()

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

Addition.

Definition at line 166 of file vec3d.h.

◆ operator-()

GfVec3d operator- ( ) const
inline

Create a vec with negated elements.

Definition at line 161 of file vec3d.h.

◆ operator-=()

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

Subtraction.

Definition at line 177 of file vec3d.h.

◆ operator/()

GfVec3d operator/ ( double  s) const
inline

Definition at line 209 of file vec3d.h.

◆ operator/=()

GfVec3d & operator/= ( double  s)
inline

Division by scalar.

Definition at line 203 of file vec3d.h.

◆ operator==() [1/4]

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

Equality comparison.

◆ operator==() [2/4]

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

Equality comparison.

◆ operator==() [3/4]

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

Equality comparison.

◆ operator==() [4/4]

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

Equality comparison.

Definition at line 140 of file vec3d.h.

◆ operator[]() [1/2]

double & operator[] ( size_t  i)
inline

Definition at line 132 of file vec3d.h.

◆ operator[]() [2/2]

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

Indexing.

Definition at line 131 of file vec3d.h.

◆ OrthogonalizeBasis()

static GF_API bool OrthogonalizeBasis ( GfVec3d tx,
GfVec3d ty,
GfVec3d 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]

GfVec3d & Set ( double const *  a)
inline

Set all elements with a pointer to data.

Definition at line 121 of file vec3d.h.

◆ Set() [2/2]

GfVec3d & Set ( double  s0,
double  s1,
double  s2 
)
inline

Set all elements with passed arguments.

Definition at line 113 of file vec3d.h.

◆ XAxis()

static GfVec3d XAxis ( )
inlinestatic

Create a unit vector along the X-axis.

Definition at line 85 of file vec3d.h.

◆ YAxis()

static GfVec3d YAxis ( )
inlinestatic

Create a unit vector along the Y-axis.

Definition at line 91 of file vec3d.h.

◆ ZAxis()

static GfVec3d ZAxis ( )
inlinestatic

Create a unit vector along the Z-axis.

Definition at line 97 of file vec3d.h.

Friends And Related Function Documentation

◆ hash_value

size_t hash_value ( GfVec3d const &  vec)
friend

Hash.

Definition at line 135 of file vec3d.h.

◆ operator*

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

Definition at line 197 of file vec3d.h.

◆ operator+

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

Definition at line 172 of file vec3d.h.

◆ operator-

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

Definition at line 183 of file vec3d.h.

Member Data Documentation

◆ dimension

const size_t dimension = 3
static

Definition at line 50 of file vec3d.h.


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