8#ifndef META_OCEAN_MATH_VECTOR4_H
9#define META_OCEAN_MATH_VECTOR4_H
119 inline VectorT4(
const T&
x,
const T&
y,
const T&
z,
const T&
w)
noexcept;
139 inline explicit VectorT4(
const T* valueArray)
noexcept;
152 template <
typename U>
229 inline const T&
x() const noexcept;
235 inline T&
x() noexcept;
241 inline const T&
y() const noexcept;
247 inline T&
y() noexcept;
253 inline const T&
z() const noexcept;
259 inline T&
z() noexcept;
265 inline const T&
w() const noexcept;
271 inline T&
w() noexcept;
289 inline const T*
data() const noexcept;
329 inline
bool operator==(const
VectorT4<T>& vector) const;
336 inline
bool operator!=(const
VectorT4<T>& vector) const;
377 inline T operator*(const
VectorT4<T>& vector) const;
384 inline
VectorT4<T> operator*(const T& value) const;
401 inline
VectorT4<T> operator/(const T& value) const;
419 inline
bool operator<(const
VectorT4<T>& vector) const;
426 inline const T& operator[](const
unsigned int index) const noexcept;
433 inline T& operator[](const
unsigned int index) noexcept;
440 inline const T& operator()(const
unsigned int index) const noexcept;
447 inline T& operator()(const
unsigned int index) noexcept;
453 inline const T* operator()() const noexcept;
459 inline T* operator()() noexcept;
466 inline
size_t operator()(const
VectorT4<T>& vector) const;
486 template <typename U>
495 template <typename U>
505 template <typename U>
526 memcpy(
values_, vector(),
sizeof(T) * 3);
533 memcpy(
values_, vector(),
sizeof(T) * 3);
540 memcpy(
values_, valueArray,
sizeof(T) * 4);
559 ocean_assert(
false &&
"Division by zero!");
563 T factor = T(1) / len;
577 const T factor = T(1) / len;
591 const T factor = T(1) / len;
604 const T factor = T(1) / len;
631 const T thisLength =
length();
632 const T rightLength = right.
length();
636 ocean_assert(
false &&
"Invalid vector!");
651 const T dotProduct = normalizedThis * normalizedRight;
841 const T factor = T(1) / value;
851 const T factor = T(1) / value;
873 ocean_assert(index < 4u);
880 ocean_assert(index < 4u);
887 ocean_assert(index < 4u);
894 ocean_assert(index < 4u);
913 size_t seed = std::hash<T>{}(vector.
x());
914 seed ^= std::hash<T>{}(vector.
y()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
915 seed ^= std::hash<T>{}(vector.
z()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
916 seed ^= std::hash<T>{}(vector.
w()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
937 return std::move(vectors);
944 return std::move(vectors);
951 std::vector<VectorT4<T>> result;
952 result.reserve(vectors.size());
954 for (
typename std::vector<
VectorT4<U>>::const_iterator i = vectors.cbegin(); i != vectors.cend(); ++i)
956 result.emplace_back(*i);
980 std::vector<VectorT4<T>> result;
981 result.reserve(vectors.size());
983 for (
typename std::vector<
VectorT4<U>>::const_iterator i = vectors.begin(); i != vectors.end(); ++i)
985 result.emplace_back(*i);
995 std::vector<VectorT4<T>> result;
996 result.reserve(size);
998 for (
size_t n = 0; n < size; ++n)
1000 result.emplace_back(vectors[n]);
1006template <
typename T>
1009 stream <<
"[" << vector.
x() <<
", " << vector.
y() <<
", " << vector.
z() <<
", " << vector.
w() <<
"]";
1014template <
bool tActive,
typename T>
1015MessageObject<tActive>&
operator<<(MessageObject<tActive>& messageObject,
const VectorT4<T>& vector)
1017 return messageObject <<
"[" << vector.x() <<
", " << vector.y() <<
", " << vector.z() <<
", " << vector.w() <<
"]";
1020template <
bool tActive,
typename T>
1023 return messageObject <<
"[" << vector.x() <<
", " << vector.y() <<
", " << vector.z() <<
", " << vector.w() <<
"]";
Messenger object, one object for each message.
Definition Messenger.h:448
This class provides basic numeric functionalities.
Definition Numeric.h:57
static constexpr T minValue()
Returns the min scalar value.
Definition Numeric.h:3259
static T sqrt(const T value)
Returns the square root of a given value.
Definition Numeric.h:1537
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition Numeric.h:2395
static constexpr bool isEqualEps(const T value)
Returns whether a value is smaller than or equal to a small epsilon.
Definition Numeric.h:2096
static T acos(const T value)
Returns the arccosine of a given value.
Definition Numeric.h:2916
static constexpr bool isNotEqualEps(const T value)
Returns whether a value is not smaller than or equal to a small epsilon.
Definition Numeric.h:2246
static bool isNotEqual(const T first, const T second)
Returns whether two values are not equal up to a small epsilon.
Definition Numeric.h:2622
static constexpr T maxValue()
Returns the max scalar value.
Definition Numeric.h:3253
This class implements a vector with two elements.
Definition Vector2.h:96
This class implements a vector with three elements.
Definition Vector3.h:97
This class implements a vector with four elements.
Definition Vector4.h:97
VectorT4< T > operator/(const T &value) const
Divides this vector by a scalar.
Definition Vector4.h:838
VectorT3< Scalar > xyz() const noexcept
bool isOrthogonal(const VectorT4< T > &right) const
Returns whether two vectors are orthogonal.
Definition Vector4.h:657
static std::vector< VectorT4< Scalar > > vectors2vectors(std::vector< VectorT4< U > > &&vectors)
const T * operator()() const noexcept
Access operator.
Definition Vector4.h:899
VectorT4< T > normalizedOrZero() const
Returns the normalized vector.
Definition Vector4.h:568
bool operator==(const VectorT4< T > &vector) const
Returns whether two vectors are identical up to a small epsilon.
Definition Vector4.h:757
T length() const
Returns the length of the vector.
Definition Vector4.h:613
const Scalar & y() const noexcept
VectorT4(const VectorT3< T > &vector) noexcept
Creates a new homogeneous 4D vector by a 3D vector.
Definition Vector4.h:524
const Scalar & x() const noexcept
bool operator!=(const VectorT4< T > &vector) const
Returns whether two vectors are not identical up to a small epsilon.
Definition Vector4.h:766
VectorT4< T > & operator+=(const VectorT4< T > &vector)
Adds and assigns two vectors.
Definition Vector4.h:781
bool isEqual(const VectorT4< Scalar > &vector, const Scalar eps) const
const Scalar * data() const noexcept
const Scalar & z() const noexcept
VectorT4()=default
Creates a new 2D vector with zeros as default values.
Scalar Type
Definition Vector4.h:103
VectorT4< T > normalized() const
Returns the normalized vector.
Definition Vector4.h:554
VectorT4< T > & operator/=(const T &value)
Divides and assigns this vector by a scalar.
Definition Vector4.h:847
VectorT4< T > & operator*=(const T &value)
Multiplies and assigns this vector with a scalar.
Definition Vector4.h:827
static VectorT4< Scalar > maxValue()
bool isUnit(const Scalar eps=NumericT< Scalar >::eps()) const
VectorT4< T > normalizedOrValue(const VectorT4< T > &value) const
Returns the normalized vector.
Definition Vector4.h:582
Scalar values_[4]
Definition Vector4.h:511
VectorT4(const VectorT3< T > &vector, const T &w) noexcept
Creates a new 4D vector by a 3D vector and a following scalar.
Definition Vector4.h:531
const T & operator[](const unsigned int index) const noexcept
Element access operator.
Definition Vector4.h:871
T operator*(const VectorT4< T > &vector) const
Returns the dot product of two vectors.
Definition Vector4.h:815
static VectorT4< Scalar > minValue()
VectorT4(const VectorT4< T > &vector) noexcept=default
Copies a vector.
VectorT4< T > operator+(const VectorT4< T > &vector) const
Adds two vectors.
Definition Vector4.h:775
VectorT4(const VectorT4< U > &vector) noexcept
Copies a vector with different element data type than T.
Definition Vector4.h:545
T sqr() const
Returns the square of the vector length.
Definition Vector4.h:619
VectorT4(const T *valueArray) noexcept
Creates a new 4D vector with a given array of elements.
Definition Vector4.h:538
const Scalar & w() const noexcept
bool normalize()
Normalizes this vector.
Definition Vector4.h:596
VectorT4< T > & operator-=(const VectorT4< T > &vector)
Subtracts and assigns two vectors.
Definition Vector4.h:798
VectorT4(const T &x, const T &y, const T &z, const T &w) noexcept
Creates a new 4D vector with four given elements.
Definition Vector4.h:515
VectorT2< Scalar > xy() const noexcept
VectorT4< T > operator-() const
Returns the negated vector.
Definition Vector4.h:809
bool operator<(const VectorT4< T > &vector) const
Compares two vector objects and returns whether the left vector represents a smaller value than the r...
Definition Vector4.h:862
T angle(const VectorT4< T > &right) const
Returns the angle between this vector and a second vectors.
Definition Vector4.h:625
bool isParallel(const VectorT4< T > &right) const
Returns whether two vectors are parallel.
Definition Vector4.h:646
VectorT4< int > VectorI4
Definition of a 4D vector with integer values.
Definition Vector4.h:50
std::vector< VectorF4 > VectorsF4
Definition of a vector holding VectorF4 objects.
Definition Vector4.h:79
std::vector< Vector4 > Vectors4
Definition of a vector holding Vector4 objects.
Definition Vector4.h:65
VectorT4< double > VectorD4
Definition of a 4D vector with double values.
Definition Vector4.h:36
std::vector< VectorD4 > VectorsD4
Definition of a vector holding VectorD4 objects.
Definition Vector4.h:72
VectorT4< Scalar > Vector4
Definition of a 4D vector.
Definition Vector4.h:29
std::vector< VectorT4< T > > VectorsT4
Definition of a typename alias for vectors with VectorT4 objects.
Definition Vector4.h:58
VectorT4< float > VectorF4
Definition of a 4D vector with float values.
Definition Vector4.h:43
std::vector< VectorI4 > VectorsI4
Definition of a vector holding VectorI4 objects.
Definition Vector4.h:86
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
std::ostream & operator<<(std::ostream &stream, const HighPerformanceStatistic &highPerformanceStatistic)
Definition HighPerformanceTimer.h:963