#include <vec2.h>
A vector consisting of two components X and Y.
Public Types | |
template<typename U > | |
using | Rebind = Vec2< U, STRIDE, SPACE > |
using | VectorStrideType = std::integral_constant< Int, STRIDE > |
using | ValueType = T |
using | ValueTypeParam = typename ByValueParam< T >::type |
using | Unstrided = Vec2< T, 1, SPACE > |
using | BoolType = decltype(T()==T()) |
Public Member Functions | |
constexpr | Vec2 () |
constexpr | Vec2 (ValueTypeParam in) |
constexpr | Vec2 (ValueTypeParam ix, ValueTypeParam iy) |
template<typename T2 , Int S2> | |
constexpr | Vec2 (const Vec2< T2, S2, SPACE > &v) |
template<Int S2> | |
constexpr | Vec2 (const Vec2< T, S2, SPACE > &v) |
template<typename T2 , Int S2> | |
constexpr | Vec2 (const Vec3< T2, S2 > &v) |
constexpr | Vec2 (ENUM_DONT_INITIALIZE v) |
constexpr MAXON_IMPLICIT | Vec2 (const typename std::conditional< STRIDE==1, DummyParamType, Vec2 >::type &src) |
Vec2 & | operator= (const typename std::conditional< STRIDE==1, DummyParamType, Vec2 >::type &src) |
T & | operator[] (Int l) |
ValueTypeParam | operator[] (Int l) const |
template<typename T2 , Int S2> | |
Vec2 & | operator+= (const Vec2< T2, S2, SPACE > &v) |
Vec2 & | operator+= (const Vec2 &v) |
template<typename T2 , Int S2> | |
Vec2 & | operator-= (const Vec2< T2, S2, SPACE > &v) |
Vec2 & | operator-= (const Vec2 &v) |
template<typename T2 , Int S2> | |
Vec2 & | operator*= (const Vec2< T2, S2, SPACE > &v) |
Vec2 & | operator*= (const Vec2 &v) |
Vec2 & | operator*= (ValueTypeParam s) |
Vec2 & | operator/= (ValueTypeParam s) |
constexpr Unstrided | operator* (ValueTypeParam s) const |
template<typename S > | |
constexpr Vec2< typename MultiplicativePromotion< T, S, STD_IS_REPLACEMENT(scalar, S)>::type, 1, SPACE > | operator* (S s) const |
constexpr Unstrided | operator/ (ValueTypeParam s) const |
constexpr Unstrided | operator* (const Vec2 &v) const |
constexpr Unstrided | operator+ (const Vec2 &v) const |
constexpr Unstrided | operator- (const Vec2 &v) const |
constexpr Unstrided | operator- () const |
template<typename T2 , Int S2> | |
constexpr BoolType | operator== (const Vec2< T2, S2, SPACE > &v) const |
constexpr BoolType | operator== (const Vec2 &v) const |
template<typename T2 , Int S2> | |
constexpr BoolType | operator!= (const Vec2< T2, S2, SPACE > &v) const |
constexpr BoolType | operator!= (const Vec2 &v) const |
constexpr BoolType | operator<= (const Vec2 &v) const |
constexpr BoolType | operator>= (const Vec2 &v) const |
constexpr BoolType | operator< (const Vec2 &v) const |
constexpr BoolType | operator> (const Vec2 &v) const |
constexpr HashInt | GetHashCode () const |
UniqueHash | GetUniqueHashCode () const |
BoolType | IsEqual (const Vec2 &other, ValueTypeParam epsilon) const |
constexpr BoolType | IsZero () const |
void | SetZero () |
constexpr T | GetAverage () const |
constexpr T | GetSum () const |
void | ClampMin (const Vec2 &other=Vec2()) |
void | ClampMax (const Vec2 &other) |
constexpr Unstrided | Clamp01 () const |
T | GetLength () const |
constexpr T | GetSquaredLength () const |
Unstrided | GetNormalized () const |
Unstrided | operator! () const |
void | Normalize () |
String | ToString (const FormatStatement *formatStatement=nullptr) const |
constexpr T | GetMin () const |
constexpr T | GetMax () const |
constexpr Unstrided | GetRightRotated (Int rots) const |
template<typename T2 > | |
Vec2 & | operator*= (const Mat2< T2 > &m) |
Static Public Member Functions | |
static MAXON_ATTRIBUTE_FORCE_INLINE const Vec2 & | NullValue () |
Public Attributes | |
union { | |
T x | |
T _xpadding [STRIDE] | |
}; | |
union { | |
T y | |
T _ypadding [STRIDE] | |
}; | |
Friends | |
constexpr friend Unstrided | operator* (ValueTypeParam s, const Vec2 &v) |
constexpr friend T | Dot (const Vec2 &v1, const Vec2 &v2) |
Unstrided | Abs (const Vec2 &v1) |
template<typename T2 , Int S2> | |
constexpr friend MultiplicativePromotion< T, T2 >::type | Dot (const Vec2 &v1, const Vec2< T2, S2, SPACE > &v2) |
constexpr friend Unstrided | Min (const Vec2 &a, const Vec2 &other) |
constexpr friend Unstrided | Max (const Vec2 &a, const Vec2 &other) |
void | SetMin (Vec2 &a, const Vec2 &other) |
void | SetMax (Vec2 &a, const Vec2 &other) |
T | GetAngle (const Vec2 &v1, const Vec2 &v2) |
constexpr friend Unstrided | Cross (const Vec2 &v1) |
using VectorStrideType = std::integral_constant<Int, STRIDE> |
using ValueType = T |
using ValueTypeParam = typename ByValueParam<T>::type |
using BoolType = decltype(T() == T()) |
The type returned by comparisons. If the template argument for T is a SIMD type, this will be a SIMD type, too, which contains the per-element results.
|
constexpr |
Initializes all vector components with 0.0.
|
explicitconstexpr |
Initializes all vector components with a scalar.
|
explicitconstexpr |
Initializes all vector components individually.
Initializes components from another 2d vector.
Initializes components from another 2d vector.
Initializes components from a 3d vector. The z-component of v is ignored.
|
explicitconstexpr |
Skips initialization of vector (for better speed)
|
constexpr |
When STRIDE is not 1, we have to provide copy constructor and operator because the default ones would also copy the padding. When STRIDE is 1, we want to avoid to declare them (because then the type wouldn't be trivially copyable any longer), so we use DummyParamType for the parameter in that case.
Vec2& operator= | ( | const typename std::conditional< STRIDE==1, DummyParamType, Vec2< T, STRIDE, SPACE > >::type & | src | ) |
Copies the source vector.
[in] | src | Source vector. |
T& operator[] | ( | Int | l | ) |
Accesses vector component: index 0 is 'x', index 1 is 'y'. All other values must not be used and will crash.
ValueTypeParam operator[] | ( | Int | l | ) | const |
Accesses vector component: index 0 is 'x', index 1 is 'y'. All other values must not be used and will crash.
Adds a vector. We repeat the function template as non-template function, this allows the usage in contexts where the parameter is not a vector itself, but something with a conversion operator to a vector.
[in] | v | Vector to be added. |
Subtracts a vector. We repeat the function template as non-template function, this allows the usage in contexts where the parameter is not a vector itself, but something with a conversion operator to a vector.
[in] | v | Vector to be substracted from this. |
Multiplies with vector component-wise. We repeat the function template as non-template function, this allows the usage in contexts where the parameter is not a vector itself, but something with a conversion operator to a vector.
[in] | v | Vector to be multiplied with. |
Vec2& operator*= | ( | ValueTypeParam | s | ) |
Multiplies each vector component by a scalar.
Vec2& operator/= | ( | ValueTypeParam | s | ) |
Divides each vector component by a scalar. The passed argument is checked for 0.0.
|
constexpr |
Multiplies each vector component by a scalar.
|
constexpr |
Multiplies each vector component by a scalar.
|
constexpr |
Divides each vector component by a scalar. The scalar value is tested for 0.0.
Multiplies two vectors component-wise.
Adds two vectors.
Subtracts vector v2 from v1.
|
constexpr |
Negates vector v.
Equality operator. We repeat the function template as non-template function, this allows the usage in contexts where the parameter is not a vector itself, but something with a conversion operator to a vector
[in] | v | Comparison vector. |
Equality operator. We repeat the function template as non-template function, this allows the usage in contexts where the parameter is not a vector itself, but something with a conversion operator to a vector
[in] | v | Comparison vector. |
Inequality operator.
[in] | v | Comparison vector. |
Inequality operator. We repeat the function template as non-template function, this allows the usage in contexts where the parameter is not a vector itself, but something with a conversion operator to a vector
[in] | v | Comparison vector. |
Compares this vector with v. Note that this doesn't define a total order but just a partial order, so for a pair of vectors it can happen that neither {v <= w} nor
{v >= w}.
[in] | v | Comparison vector. |
Compares this vector with v. Note that this doesn't define a total order but just a partial order, so for a pair of vectors it can happen that neither {v <= w} nor
{v >= w}.
[in] | v | Comparison vector. |
Compares this vector with v. Note that this doesn't define a total order but just a partial order, so for a pair of vectors it can happen that neither {v < w} nor
{v > w} nor
{v == w}. Also note that
{v < w} is not the same as
{v <= w && v != w}.
[in] | v | Comparison vector. |
Compares this vector with v. Note that this doesn't define a total order but just a partial order, so for a pair of vectors it can happen that neither {v < w} nor
{v > w} nor
{v == w}. Also note that
{v > w} is not the same as
{v >= w && v != w}.
[in] | v | Comparison vector. |
|
constexpr |
Returns the hash code of the vector (used for hash maps and comparisons).
UniqueHash GetUniqueHashCode | ( | ) | const |
BoolType IsEqual | ( | const Vec2< T, STRIDE, SPACE > & | other, |
ValueTypeParam | epsilon | ||
) | const |
Tests component-wise if the difference is no bigger than 'epsilon'.
|
constexpr |
Checks if each component is zero.
void SetZero | ( | ) |
Sets all components to zero.
|
constexpr |
Calculates the average value of 'x', 'y' and 'z'.
|
constexpr |
Calculates the sum of 'x', 'y' and 'z'.
Set the minimum of each component.
|
constexpr |
Returns a vector that is clamped to the range [0.0 .. 1.0].
T GetLength | ( | ) | const |
Returns the length of the vector.
|
constexpr |
Returns the squared length of the vector.
Unstrided GetNormalized | ( | ) | const |
Returns a normalized vector, so that GetLength(vector)==1.0.
Unstrided operator! | ( | ) | const |
Returns a normalized vector, so that GetLength(vector)==1.0.
void Normalize | ( | ) |
Normalizes this vector, so that GetLength()==1.0.
String ToString | ( | const FormatStatement * | formatStatement = nullptr | ) | const |
Returns a readable string of the content.
[in] | formatStatement | Nullptr or additional formatting instruction. See also Formatting Floating point values. |
|
constexpr |
Returns the minimum of 'x' and 'y'.
|
constexpr |
Returns the maximum of 'x' and 'y'.
Returns a vector where the components have been rotated to the right (in the usual (x, y)-representation). E.g., with a value of 1 for rots, the result will be (y, x).
[in] | rots | Number of rotations, may be negative. The result depends only on the number modulo 2. |
|
static |
Returns a null value of the vector (see nullvalue.h for more details).
|
friend |
Multiplies each vector component by a scalar.
|
friend |
Calculates dot product of v1 and v2.
returns the vector with absolute value for each entry
[in] | v1 | input vector to work on |
|
friend |
Calculates dot product of v1 and v2.
|
friend |
Calculates the minimum of each component.
|
friend |
Calculates the maximum of each component.
Set the minimum of each component.
Set the maximum of each component.
Calculates angle (in radians) between v1 and v2.
Calculates the cross product of a 2d vector. This is the vector (Y, -X), i.e., the clockwise rotation by 90 degrees.
T x |
T _xpadding[STRIDE] |
union { ... } |
T y |
T _ypadding[STRIDE] |
union { ... } |