Template Struct Quat¶
Defined in File quat.hpp
Inheritance Relationships¶
Base Type¶
public ripple::PolymorphicLayout< Quat< T, ContiguousOwned > >
(Template Struct PolymorphicLayout)
Struct Documentation¶
-
template<typename
T
, typenameLayout
= ContiguousOwned>
structripple
::
Quat
: public ripple::PolymorphicLayout<Quat<T, ContiguousOwned>>¶ The Quat class implements a quaternion class with polymorphic data layout.
The data for the elements is allocated according to the layout, and can be contiguous, owned, or strided.
- Template Parameters
T
: The type of the elements in the quaternionLayout
: The type of the storage layout for the quaternion
Public Functions
-
constexpr
Quat
() noexcept¶ Default constructor for the quaternion, value of initialization for elements in undefined.
-
constexpr
Quat
(T val) noexcept¶ Sets all elements of the quaternion to the given value.
- Parameters
val
: The value to set all elements to.
-
template<typename ...
Values
, variadic_ge_enable_t<2, Values...> = 0>
constexprQuat
(Values&&... values) noexcept¶ Constructor to create the quaternion from a list of values.
The first value is the scalar component, the rest are the vector component.
- Note
The order of initialization is {scalar, vx, vy, vz}, and elements which are not specified are set to zero, i.e if 1, 1 are specified then the quaternion is initialized to
{1, [1 0 0]}
.- Note
This overload is only enabled when the number of elements in the variadic parameter is two or more.
- Note
The types of the values must be convertible to T.
- Parameters
values
: The values to set the elements to.
- Template Parameters
Values
: The types of the values for setting.
-
constexpr
Quat
(Storage storage) noexcept¶ Constructor to set the quaternion from the other storage.
- Parameters
other
: The other storage to use to set the quaternion.
-
constexpr
Quat
(const Quat &other) noexcept¶ Copy constructor to set the quaternion from another quaternion.
- Parameters
other
: The other quaternion to use to initialize this one.
-
constexpr
Quat
(Quat &&other) noexcept¶ Move constructor to set the quaternion from another quaternion.
- Parameters
other
: The other quaternion to use to initialize this one.
-
template<typename
OtherLayout
>
constexprQuat
(const Quat<T, OtherLayout> &other) noexcept¶ Copy constructor to set the quaternion from another quaternion with different storage layout.
- Parameters
other
: The other quaternion to use to initialize this one.
- Template Parameters
OtherLayout
: The layout of the other storage.
-
template<typename
OtherLayout
>
constexprQuat
(Quat<T, OtherLayout> &&other) noexcept¶ Move constructor to set the quaternion from another quaternion with a different storage layout.
- Parameters
other
: The other quaternion to use to initialize this one.
- Template Parameters
OtherLayout
: The layout of the other storage.
-
auto
operator=
(const Quat &other) noexcept -> Quat&¶ Overload of copy assignment overload to copy the elements from another quaternion to this matrix.
- Return
A references to the modified quaternion.
- Parameters
other
: The other quaternion to copy from.
-
auto
operator=
(Quat &&other) noexcept -> Quat&¶ Overload of move assignment overload to move the elements from another quaternion to this quaternion.
- Return
A reference to the modified quaternion.
- Parameters
other
: The other quaternion to move.
-
template<typename
OtherLayout
>
autooperator=
(const Quat<T, OtherLayout> &other) noexcept -> Quat&¶ Overload of copy assignment overload to copy the elements from another quaternion with a different storage layout to this quaternion.
- Return
A reference to the modified quaternion.
- Parameters
other
: The other quaternion to copy from.
- Template Parameters
OtherLayout
: The layout of the other quaternion.
-
template<typename
OtherLayout
>
autooperator=
(Quat<T, OtherLayout> &&other) noexcept -> Quat&¶ Overload of move assignment overload to copy the elements from another quaternion to this quaternion.
- Return
A reference to the modified quaternion.
- Parameters
other
: The other quaternion to move.
- Template Parameters
OtherLayout
: The layout of the other quaternion.
-
auto
operator[]
(size_t i) noexcept -> Value&¶ Overload of access operator to get the element at the given index.
The access pattern is [scalar, vx, vy, vz].
- Return
A reference to the element.
- Parameters
i
: The index of the element to get.
-
auto
scalar
() noexcept -> Value&¶ Gets the scalar part of the quaternion.
- Return
A reference to the scalar part of the quaternion.
-
auto
scalar
() const noexcept -> const Value&¶ Gets the scalar part of the quaternion.
- Return
A const reference to the scalar part of the quaternion.
-
template<size_t
I
>
autovec_component
() noexcept -> Value&¶ Gets the Ith vector component from the quaternion.
- Template Parameters
I
: The index of the vector component to get.
-
template<size_t
I
>
autovec_component
() const noexcept -> const Value&¶ Gets the Ith vector component from the quaternion.
- Template Parameters
I
: The index of the vector component to get.
-
auto
vec_component
(size_t i) noexcept -> Value&¶ Gets the Ith vector component from the quaternion.
- Template Parameters
i
: The index of the vector component to get.
-
auto
vec_component
(size_t i) const noexcept -> const Value&¶ Gets the Ith vector component from the quaternion.
- Template Parameters
I
: The index of the vector component to get.
-
auto
length_squared
() const noexcept -> Value¶ Gets the length squared of the quaternion.
- Return
The squared length of the quaternion.
-
auto
length
() const noexcept -> Value¶ Gets the length of the quaternion.
- Return
The length of the quaternion.
-
auto
normalize
() noexcept -> void¶ Normalizes the quaternion.
-
auto
invert
() noexcept -> void¶ Inverts the quaternion.
-
auto
inverse
() const noexcept -> Quat<T, ContiguousOwned>¶ Gets the inverse of the quaternion.
- Return
A new quaternion which is the inverse of this quaternion.