All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GfVec2d Class Reference

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

Public Types

typedef double ScalarType
 Scalar element type and dimension. More...
 

Public Member Functions

 GfVec2d ()=default
 Default constructor does no initialization. More...
 
constexpr GfVec2d (double value)
 Initialize all elements to a single value. More...
 
constexpr GfVec2d (double s0, double s1)
 Initialize all elements with explicit arguments. More...
 
template<class Scl >
constexpr GfVec2d (Scl const *p)
 Construct with pointer to values. More...
 
 GfVec2d (class GfVec2f const &other)
 Implicitly convert from GfVec2f. More...
 
 GfVec2d (class GfVec2h const &other)
 Implicitly convert from GfVec2h. More...
 
 GfVec2d (class GfVec2i const &other)
 Implicitly convert from GfVec2i. More...
 
GfVec2dSet (double s0, double s1)
 Set all elements with passed arguments. More...
 
GfVec2dSet (double const *a)
 Set all elements with a pointer to data. More...
 
double const * data () const
 Direct data access. More...
 
double * data ()
 
double const * GetArray () const
 
double const & operator[] (size_t i) const
 Indexing. More...
 
double & operator[] (size_t i)
 
bool operator== (GfVec2d const &other) const
 Equality comparison. More...
 
bool operator!= (GfVec2d const &other) const
 
GF_API bool operator== (class GfVec2f const &other) const
 Equality comparison. More...
 
GF_API bool operator== (class GfVec2h const &other) const
 Equality comparison. More...
 
GF_API bool operator== (class GfVec2i const &other) const
 Equality comparison. More...
 
GfVec2d operator- () const
 Create a vec with negated elements. More...
 
GfVec2doperator+= (GfVec2d const &other)
 Addition. More...
 
GfVec2doperator-= (GfVec2d const &other)
 Subtraction. More...
 
GfVec2doperator*= (double s)
 Multiplication by scalar. More...
 
GfVec2d operator* (double s) const
 
GfVec2doperator/= (double s)
 Division by scalar. More...
 
GfVec2d operator/ (double s) const
 
double operator* (GfVec2d const &v) const
 See GfDot(). More...
 
GfVec2d GetProjection (GfVec2d const &v) const
 Returns the projection of this onto v. More...
 
GfVec2d GetComplement (GfVec2d const &b) const
 Returns the orthogonal complement of this->GetProjection(b). More...
 
double GetLengthSq () const
 Squared length. More...
 
double GetLength () const
 Length. More...
 
double Normalize (double eps=GF_MIN_VECTOR_LENGTH)
 Normalizes the vector in place to unit length, returning the length before normalization. More...
 
GfVec2d GetNormalized (double eps=GF_MIN_VECTOR_LENGTH) const
 

Static Public Member Functions

static GfVec2d XAxis ()
 Create a unit vector along the X-axis. More...
 
static GfVec2d YAxis ()
 Create a unit vector along the Y-axis. More...
 
static GfVec2d Axis (size_t i)
 Create a unit vector along the i-th axis, zero-based. More...
 

Static Public Attributes

static const size_t dimension = 2
 

Friends

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

Detailed Description

Basic type for a vector of 2 double components.

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

Definition at line 63 of file vec2d.h.

Member Typedef Documentation

typedef double ScalarType

Scalar element type and dimension.

Definition at line 67 of file vec2d.h.

Constructor & Destructor Documentation

GfVec2d ( )
default

Default constructor does no initialization.

constexpr GfVec2d ( double  value)
inlineexplicit

Initialize all elements to a single value.

Definition at line 74 of file vec2d.h.

constexpr GfVec2d ( double  s0,
double  s1 
)
inline

Initialize all elements with explicit arguments.

Definition at line 80 of file vec2d.h.

constexpr GfVec2d ( Scl const *  p)
inlineexplicit

Construct with pointer to values.

Definition at line 87 of file vec2d.h.

GfVec2d ( class GfVec2f const &  other)
inline

Implicitly convert from GfVec2f.

Definition at line 296 of file vec2d.h.

GfVec2d ( class GfVec2h const &  other)
inline

Implicitly convert from GfVec2h.

Definition at line 302 of file vec2d.h.

GfVec2d ( class GfVec2i const &  other)
inline

Implicitly convert from GfVec2i.

Definition at line 308 of file vec2d.h.

Member Function Documentation

static GfVec2d 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 2.

Definition at line 116 of file vec2d.h.

double const* data ( ) const
inline

Direct data access.

Definition at line 136 of file vec2d.h.

GfVec2d GetComplement ( GfVec2d const &  b) const
inline

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

That is:

* *this - this->GetProjection(b)
*

Definition at line 240 of file vec2d.h.

double GetLength ( ) const
inline

Length.

Definition at line 250 of file vec2d.h.

double GetLengthSq ( ) const
inline

Squared length.

Definition at line 245 of file vec2d.h.

GfVec2d GetProjection ( GfVec2d const &  v) const
inline

Returns the projection of this onto v.

That is:

* v * (*this * v)
*

Definition at line 231 of file vec2d.h.

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 263 of file vec2d.h.

double operator* ( GfVec2d const &  v) const
inline

See GfDot().

Definition at line 223 of file vec2d.h.

GfVec2d& operator*= ( double  s)
inline

Multiplication by scalar.

Definition at line 198 of file vec2d.h.

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

Addition.

Definition at line 178 of file vec2d.h.

GfVec2d operator- ( ) const
inline

Create a vec with negated elements.

Definition at line 173 of file vec2d.h.

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

Subtraction.

Definition at line 188 of file vec2d.h.

GfVec2d& operator/= ( double  s)
inline

Division by scalar.

Definition at line 212 of file vec2d.h.

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

Equality comparison.

Definition at line 153 of file vec2d.h.

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

Equality comparison.

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

Equality comparison.

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

Equality comparison.

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

Indexing.

Definition at line 141 of file vec2d.h.

GfVec2d& Set ( double  s0,
double  s1 
)
inline

Set all elements with passed arguments.

Definition at line 124 of file vec2d.h.

GfVec2d& Set ( double const *  a)
inline

Set all elements with a pointer to data.

Definition at line 131 of file vec2d.h.

static GfVec2d XAxis ( )
inlinestatic

Create a unit vector along the X-axis.

Definition at line 102 of file vec2d.h.

static GfVec2d YAxis ( )
inlinestatic

Create a unit vector along the Y-axis.

Definition at line 108 of file vec2d.h.

Friends And Related Function Documentation

size_t hash_value ( GfVec2d const &  vec)
friend

Hash.

Definition at line 145 of file vec2d.h.


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