|
Basic type for a vector of 2 float components. More...
#include <vec2f.h>
Public Types | |
typedef float | ScalarType |
Scalar element type and dimension. | |
Public Member Functions | |
GfVec2f ()=default | |
Default constructor does no initialization. | |
constexpr | GfVec2f (float value) |
Initialize all elements to a single value. | |
constexpr | GfVec2f (float s0, float s1) |
Initialize all elements with explicit arguments. | |
template<class Scl > | |
constexpr | GfVec2f (Scl const *p) |
Construct with pointer to values. | |
GfVec2f (class GfVec2d const &other) | |
Construct from GfVec2d. | |
GfVec2f (class GfVec2h const &other) | |
Implicitly convert from GfVec2h. | |
GfVec2f (class GfVec2i const &other) | |
Implicitly convert from GfVec2i. | |
GfVec2f & | Set (float s0, float s1) |
Set all elements with passed arguments. | |
GfVec2f & | Set (float const *a) |
Set all elements with a pointer to data. | |
float const * | data () const |
Direct data access. | |
float * | data () |
float const * | GetArray () const |
float const & | operator[] (size_t i) const |
Indexing. | |
float & | operator[] (size_t i) |
bool | operator== (GfVec2f const &other) const |
Equality comparison. | |
bool | operator!= (GfVec2f const &other) const |
GF_API bool | operator== (class GfVec2d 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. | |
GfVec2f | operator- () const |
Create a vec with negated elements. | |
GfVec2f & | operator+= (GfVec2f const &other) |
Addition. | |
GfVec2f & | operator-= (GfVec2f const &other) |
Subtraction. | |
GfVec2f & | operator*= (double s) |
Multiplication by scalar. | |
GfVec2f | operator* (double s) const |
GfVec2f & | operator/= (double s) |
Division by scalar. | |
GfVec2f | operator/ (double s) const |
float | operator* (GfVec2f const &v) const |
See GfDot(). | |
GfVec2f | GetProjection (GfVec2f const &v) const |
Returns the projection of this onto v . | |
GfVec2f | GetComplement (GfVec2f const &b) const |
Returns the orthogonal complement of this->GetProjection(b) . | |
float | GetLengthSq () const |
Squared length. | |
float | GetLength () const |
Length. | |
float | Normalize (float eps=GF_MIN_VECTOR_LENGTH) |
Normalizes the vector in place to unit length, returning the length before normalization. | |
GfVec2f | GetNormalized (float eps=GF_MIN_VECTOR_LENGTH) const |
Static Public Member Functions | |
static GfVec2f | XAxis () |
Create a unit vector along the X-axis. | |
static GfVec2f | YAxis () |
Create a unit vector along the Y-axis. | |
static GfVec2f | Axis (size_t i) |
Create a unit vector along the i-th axis, zero-based. | |
Static Public Attributes | |
static const size_t | dimension = 2 |
Friends | |
size_t | hash_value (GfVec2f const &vec) |
Hash. | |
GfVec2f | operator+ (GfVec2f const &l, GfVec2f const &r) |
GfVec2f | operator- (GfVec2f const &l, GfVec2f const &r) |
GfVec2f | operator* (double s, GfVec2f const &v) |
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.
typedef float ScalarType |
|
default |
Default constructor does no initialization.
|
inlineexplicitconstexpr |
|
inlineconstexpr |
|
inlineexplicitconstexpr |
|
inlinestatic |
Returns the orthogonal complement of this->GetProjection(b)
.
That is:
|
inline |
|
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().
|
inline |
|
inline |
|
inline |
GF_API bool operator== | ( | class GfVec2d 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.
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |