![]() |
|
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 | |
| GfVec2f value-initializes to zero and performs no default initialization, like float or double. | |
| 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 |
Swizzles | |
Each accessor returns a new vector built from this one's components, in the order named. For example yx() returns GfVec2f(y, x). Every permutation of 2 to 2 of the 2 components is available. Repeated components ( 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 GfVec2f | xy () const |
| constexpr GfVec2f | yx () 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. | |
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 For multi-component access see the swizzle accessors below, which return a new vector by value. | |
| float | x |
| float | y |
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.
| float ScalarType |
|
default |
GfVec2f value-initializes to zero and performs no default initialization, like float or double.
|
inlineexplicitconstexpr |
|
inlineconstexpr |
|
inlineexplicitconstexpr |
|
inlinestatic |
|
inline |
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 |