16 #ifndef MATHFU_INTERNAL_VECTOR_2_H_
17 #define MATHFU_INTERNAL_VECTOR_2_H_
27 static const int d = 2;
32 MATHFU_VECTOR_OPERATION(
data_[i] = v.data_[i]);
37 MATHFU_VECTOR_OPERATION(
data_[i] = static_cast<T>(v[i]));
40 explicit inline Vector(
const T& s) { MATHFU_VECTOR_OPERATION(
data_[i] = s); }
42 explicit inline Vector(
const T* a) {
43 MATHFU_VECTOR_OPERATION(
data_[i] = a[i]);
46 inline Vector(
const T& s1,
const T& s2) {
52 MATHFU_VECTOR_OPERATION(
data_[i] = vector.data[i]);
68 MATHFU_VECTOR_OPERATION(vector->data[i] =
data_[i]);
79 template <
typename CompatibleT>
81 return FromTypeHelper<T, d, CompatibleT>(compatible);
84 template <
typename CompatibleT>
86 return ToTypeHelper<T, d, CompatibleT>(v);
90 return DotProductHelper(v1, v2);
120 #include "mathfu/internal/disable_warnings_begin.h"
128 #include "mathfu/internal/disable_warnings_end.h"
152 #include "mathfu/internal/disable_warnings_begin.h"
161 #include "mathfu/internal/disable_warnings_end.h"
166 #endif // MATHFU_INTERNAL_VECTOR_2_H_
T LengthHelper(const Vector< T, d > &v)
Calculate the length of a vector.
Definition: vector.h:787
T LengthSquared() const
Calculate the squared length of this vector.
Definition: vector.h:380
Vector of d elements with type T.
Definition: vector.h:63
Definition: vector_2.h:24
static Vector< T, d > Min(const Vector< T, d > &v1, const Vector< T, d > &v2)
Compare each component and returns min values.
Definition: vector.h:487
T & operator[](const int i)
Access an element of the vector.
Definition: vector.h:306
T Length() const
Calculate the length of this vector.
Definition: vector.h:385
#define MATHFU_DEFINE_CLASS_SIMD_AWARE_NEW_DELETE
Macro which defines the new and delete for MathFu classes.
Definition: utilities.h:600
Vector< T, d > NormalizedHelper(const Vector< T, d > &v)
Calculate the normalized version of a vector.
Definition: vector.h:807
static Vector< T, d > Max(const Vector< T, d > &v1, const Vector< T, d > &v2)
Compare each component and returns max values.
Definition: vector.h:477
MATHFU_DEFINE_CLASS_SIMD_AWARE_NEW_DELETE T data_[d]
Elements of the vector.
Definition: vector.h:495
Vector< T, d > MinHelper(const Vector< T, d > &v1, const Vector< T, d > &v2)
Compare each component and returns min values.
Definition: vector.h:855
T Normalize()
Normalize this vector in-place.
Definition: vector.h:390
static Vector< T, d > HadamardProduct(const Vector< T, d > &v1, const Vector< T, d > &v2)
Calculate the hadamard or componentwise product of two vectors.
Definition: vector.h:435
static CompatibleT ToType(const Vector< T, d > &v)
Load into any type that is some formulation of a length d array of type T.
Definition: vector.h:417
T LengthSquaredHelper(const Vector< T, d > &v)
Calculate the squared length of a vector.
Definition: vector.h:778
Definition: vector_2.h:132
Vector< T, d > HadamardProductHelper(const Vector< T, d > &v1, const Vector< T, d > &v2)
Calculate the hadamard or componentwise product of two vectors.
Definition: vector.h:754
VectorPacked(const Vector< T, 2 > &vector)
Definition: vector_2.h:140
Vector< T, 2 > xy()
GLSL style 2 element accessor.
Definition: vector.h:338
T data[d]
Elements of the packed vector one per dimension.
Definition: vector.h:142
Vector< T, d > Normalized() const
Calculate the normalized version of this vector.
Definition: vector.h:395
static T DotProduct(const Vector< T, d > &v1, const Vector< T, d > &v2)
Calculate the dot product of two vectors.
Definition: vector.h:426
VectorPacked()
Create an uninitialized VectorPacked.
Definition: vector_2.h:134
VectorPacked & operator=(const Vector< T, 2 > &vector)
Definition: vector_2.h:147
Vector< T, d > RandomInRangeHelper(const Vector< T, d > &min, const Vector< T, d > &max)
Generates a random vector.
Definition: vector.h:830
Packed N-dimensional vector.
Definition: vector.h:121
void Pack(VectorPacked< T, d > *const vector) const
Pack a Vector to a packed "d" element vector structure.
Definition: vector.h:373
Vector class and functions.
static Vector< T, d > RandomInRange(const Vector< T, d > &min, const Vector< T, d > &max)
Generates a random vector.
Definition: vector.h:467
T & operator()(const int i)
Access an element of the vector.
Definition: vector.h:293
static Vector< T, d > Lerp(const Vector< T, d > &v1, const Vector< T, d > &v2, const T percent)
Linearly interpolate two vectors.
Definition: vector.h:457
T NormalizeHelper(Vector< T, d > &v)
Normalize a vector in-place.
Definition: vector.h:796
Vector()
Create an uninitialized Vector.
Definition: vector.h:163
Vector< T, d > MaxHelper(const Vector< T, d > &v1, const Vector< T, d > &v2)
Compare each component and returns max values.
Definition: vector.h:843
static Vector< T, d > FromType(const CompatibleT &compatible)
Load from any type that is some formulation of a length d array of type T.
Definition: vector.h:405
Vector< T, d > LerpHelper(const Vector< T, d > &v1, const Vector< T, d > &v2, const T percent)
Linearly interpolate two vectors.
Definition: vector.h:818
T Scalar
Element type to enable reference by other classes.
Definition: vector.h:160