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

#include <vec2f.h>

Public Types

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

Public Member Functions

 GfVec2f ()=default
 Default constructor does no initialization. More...
 
constexpr GfVec2f (float value)
 Initialize all elements to a single value. More...
 
constexpr GfVec2f (float s0, float s1)
 Initialize all elements with explicit arguments. More...
 
template<class Scl >
constexpr GfVec2f (Scl const *p)
 Construct with pointer to values. More...
 
 GfVec2f (class GfVec2d const &other)
 Construct from GfVec2d. More...
 
 GfVec2f (class GfVec2h const &other)
 Implicitly convert from GfVec2h. More...
 
 GfVec2f (class GfVec2i const &other)
 Implicitly convert from GfVec2i. More...
 
GfVec2fSet (float s0, float s1)
 Set all elements with passed arguments. More...
 
GfVec2fSet (float const *a)
 Set all elements with a pointer to data. More...
 
float constdata () const
 Direct data access. More...
 
floatdata ()
 
float constGetArray () const
 
float constoperator[] (size_t i) const
 Indexing. More...
 
floatoperator[] (size_t i)
 
bool operator== (GfVec2f const &other) const
 Equality comparison. More...
 
bool operator!= (GfVec2f const &other) const
 
GF_API bool operator== (class GfVec2d 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...
 
GfVec2f operator- () const
 Create a vec with negated elements. More...
 
GfVec2foperator+= (GfVec2f const &other)
 Addition. More...
 
GfVec2foperator-= (GfVec2f const &other)
 Subtraction. More...
 
GfVec2foperator*= (double s)
 Multiplication by scalar. More...
 
GfVec2f operator* (double s) const
 
GfVec2foperator/= (double s)
 Division by scalar. More...
 
GfVec2f operator/ (double s) const
 
float operator* (GfVec2f const &v) const
 See GfDot(). More...
 
GfVec2f GetProjection (GfVec2f const &v) const
 
GfVec2f GetComplement (GfVec2f const &b) const
 
float GetLengthSq () const
 Squared length. More...
 
float GetLength () const
 Length. More...
 
float Normalize (float eps=GF_MIN_VECTOR_LENGTH)
 
GfVec2f GetNormalized (float eps=GF_MIN_VECTOR_LENGTH) const
 

Static Public Member Functions

static GfVec2f XAxis ()
 Create a unit vector along the X-axis. More...
 
static GfVec2f YAxis ()
 Create a unit vector along the Y-axis. More...
 
static GfVec2f Axis (size_t i)
 

Static Public Attributes

static const size_t dimension = 2
 

Friends

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

Detailed Description

Basic type for a vector of 2 float components.

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

Definition at line 62 of file vec2f.h.

Member Typedef Documentation

Scalar element type and dimension.

Definition at line 66 of file vec2f.h.

Constructor & Destructor Documentation

GfVec2f::GfVec2f ( )
default

Default constructor does no initialization.

constexpr GfVec2f::GfVec2f ( float  value)
inlineexplicit

Initialize all elements to a single value.

Definition at line 73 of file vec2f.h.

constexpr GfVec2f::GfVec2f ( float  s0,
float  s1 
)
inline

Initialize all elements with explicit arguments.

Definition at line 79 of file vec2f.h.

template<class Scl >
constexpr GfVec2f::GfVec2f ( Scl const p)
inlineexplicit

Construct with pointer to values.

Definition at line 86 of file vec2f.h.

PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE GfVec2f::GfVec2f ( class GfVec2d const other)
inlineexplicit

Construct from GfVec2d.

Definition at line 291 of file vec2f.h.

GfVec2f::GfVec2f ( class GfVec2h const other)
inline

Implicitly convert from GfVec2h.

Definition at line 297 of file vec2f.h.

GfVec2f::GfVec2f ( class GfVec2i const other)
inline

Implicitly convert from GfVec2i.

Definition at line 303 of file vec2f.h.

Member Function Documentation

static GfVec2f GfVec2f::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 115 of file vec2f.h.

float const* GfVec2f::data ( ) const
inline

Direct data access.

Definition at line 135 of file vec2f.h.

float* GfVec2f::data ( )
inline

Definition at line 136 of file vec2f.h.

float const* GfVec2f::GetArray ( ) const
inline

Definition at line 137 of file vec2f.h.

GfVec2f GfVec2f::GetComplement ( GfVec2f const b) const
inline

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

*this - this->GetProjection(b)

Definition at line 236 of file vec2f.h.

float GfVec2f::GetLength ( ) const
inline

Length.

Definition at line 246 of file vec2f.h.

float GfVec2f::GetLengthSq ( ) const
inline

Squared length.

Definition at line 241 of file vec2f.h.

GfVec2f GfVec2f::GetNormalized ( float  eps = GF_MIN_VECTOR_LENGTH) const
inline

Definition at line 266 of file vec2f.h.

GfVec2f GfVec2f::GetProjection ( GfVec2f const v) const
inline

Returns the projection of this onto v. That is:

v * (*this * v)

Definition at line 227 of file vec2f.h.

float GfVec2f::Normalize ( float  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().

Todo:
This was fixed for bug 67777. This is a gcc64 optimizer bug. By tickling the code, it no longer tries to write into an illegal memory address (in the code section of memory).

Definition at line 258 of file vec2f.h.

bool GfVec2f::operator!= ( GfVec2f const other) const
inline

Definition at line 153 of file vec2f.h.

GfVec2f GfVec2f::operator* ( double  s) const
inline

Definition at line 199 of file vec2f.h.

float GfVec2f::operator* ( GfVec2f const v) const
inline

See GfDot().

Definition at line 219 of file vec2f.h.

GfVec2f& GfVec2f::operator*= ( double  s)
inline

Multiplication by scalar.

Definition at line 194 of file vec2f.h.

GfVec2f& GfVec2f::operator+= ( GfVec2f const other)
inline

Addition.

Definition at line 174 of file vec2f.h.

GfVec2f GfVec2f::operator- ( ) const
inline

Create a vec with negated elements.

Definition at line 169 of file vec2f.h.

GfVec2f& GfVec2f::operator-= ( GfVec2f const other)
inline

Subtraction.

Definition at line 184 of file vec2f.h.

GfVec2f GfVec2f::operator/ ( double  s) const
inline

Definition at line 214 of file vec2f.h.

GfVec2f& GfVec2f::operator/= ( double  s)
inline

Division by scalar.

Definition at line 208 of file vec2f.h.

bool GfVec2f::operator== ( GfVec2f const other) const
inline

Equality comparison.

Definition at line 149 of file vec2f.h.

GF_API bool GfVec2f::operator== ( class GfVec2d const other) const

Equality comparison.

GF_API bool GfVec2f::operator== ( class GfVec2h const other) const

Equality comparison.

GF_API bool GfVec2f::operator== ( class GfVec2i const other) const

Equality comparison.

float const& GfVec2f::operator[] ( size_t  i) const
inline

Indexing.

Definition at line 140 of file vec2f.h.

float& GfVec2f::operator[] ( size_t  i)
inline

Definition at line 141 of file vec2f.h.

GfVec2f& GfVec2f::Set ( float  s0,
float  s1 
)
inline

Set all elements with passed arguments.

Definition at line 123 of file vec2f.h.

GfVec2f& GfVec2f::Set ( float const a)
inline

Set all elements with a pointer to data.

Definition at line 130 of file vec2f.h.

static GfVec2f GfVec2f::XAxis ( )
inlinestatic

Create a unit vector along the X-axis.

Definition at line 101 of file vec2f.h.

static GfVec2f GfVec2f::YAxis ( )
inlinestatic

Create a unit vector along the Y-axis.

Definition at line 107 of file vec2f.h.

Friends And Related Function Documentation

size_t hash_value ( GfVec2f const vec)
friend

Hash.

Definition at line 144 of file vec2f.h.

GfVec2f operator* ( double  s,
GfVec2f const v 
)
friend

Definition at line 202 of file vec2f.h.

GfVec2f operator+ ( GfVec2f const l,
GfVec2f const r 
)
friend

Definition at line 179 of file vec2f.h.

GfVec2f operator- ( GfVec2f const l,
GfVec2f const r 
)
friend

Definition at line 189 of file vec2f.h.

Member Data Documentation

const size_t GfVec2f::dimension = 2
static

Definition at line 67 of file vec2f.h.


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