|
| constexpr | AQuaternion () |
| | Default constructor. Assume elements are uninitialized.
|
| constexpr | AQuaternion (const Accessor &data) |
| | Constructor from a given accessor.
|
| constexpr | AQuaternion (const T &w, const T &x, const T &y, const T &z) |
| | Constructor to initialize all elements.
|
| constexpr | AQuaternion (const std::initializer_list< T > &list) |
| | Constructor to initialize all elements via initializer list.
|
| constexpr | ~AQuaternion ()=default |
| | Destructor.
|
| constexpr | AQuaternion (const AQuaternion< T, Accessor > &)=default |
| | Default copy constructor.
|
| constexpr | AQuaternion (AQuaternion< T, Accessor > &&)=default |
| | Default move constructor.
|
| constexpr AQuaternion< T, Accessor > & | operator= (const AQuaternion< T, Accessor > &)=default |
| | Default copy assignment operator.
|
| constexpr AQuaternion< T, Accessor > & | operator= (AQuaternion< T, Accessor > &&)=default |
| | Default move assignment operator.
|
| template<ValidQuaternionType OtherQuaternionType> |
| constexpr | AQuaternion (const OtherQuaternionType &other) &&(std |
| | Deep copy constructor with different accessor.
|
| template<ValidQuaternionType OtherQuaternionType> |
| constexpr | AQuaternion (OtherQuaternionType &&other) &&(std |
| | Deep move constructor with different accessor.
|
| template<ValidQuaternionType OtherQuaternionType> |
| constexpr AQuaternion< T, Accessor > & | operator= (const OtherQuaternionType &other) |
| | Deep copy assignment operator with different accessor.
|
| template<ValidQuaternionType OtherQuaternionType> |
| constexpr AQuaternion< T, Accessor > & | operator= (OtherQuaternionType &&other) |
| | Deep move assignment operator with different accessor.
|
| constexpr T & | operator[] (size_t index) |
| | Element access operator via a single index.
|
| constexpr const T & | operator[] (size_t index) const |
| | Const element access operator via a single index.
|
| constexpr T & | operator() (size_t index) |
| | Element access operator via a single index.
|
| constexpr const T & | operator() (size_t index) const |
| | Const element access operator via a single index.
|
| constexpr T & | w () |
| | Get a reference to the scalar component.
|
| constexpr const T & | w () const |
| | Get a reference to the scalar component.
|
| constexpr T & | x () |
| | Get a reference to the x component.
|
| constexpr const T & | x () const |
| | Get a reference to the x component.
|
| constexpr T & | y () |
| | Get a reference to the y component.
|
| constexpr const T & | y () const |
| | Get a reference to the y component.
|
| constexpr T & | z () |
| | Get a reference to the z component.
|
| constexpr const T & | z () const |
| | Get a reference to the z component.
|
| constexpr decltype(auto) | data () |
| | Get the internal data accessor.
|
| constexpr decltype(auto) | data () const |
| | Get the internal data accessor.
|
| constexpr const auto | vector () const |
| | Get a view of the quaternion vector component.
|
| constexpr auto | vector () |
| | Get a view of the quaternion vector component.
|
| constexpr deep_copy_t | copy () const |
| | Get a deep copy of the quaternion.
|
| template<typename U> |
| constexpr auto | cast () const |
| | Cast (and copy) the quaternion to a different type.
|
| constexpr void | set (const T &w, const T &x, const T &y, const T &z) |
| | Set all elements of the quaternion.
|
| constexpr void | set (const T &w, const Vector3< T > &vec) |
| | Set all elements of the quaternion.
|
| template<ValidAccessor< T > OtherAccessor> |
| constexpr void | set (const OtherAccessor &accessor) |
| | Set all elements of the vector using an accessor.
|
| constexpr void | set_vector (const Vector3< T > &vec) |
| | Set the quaternion vector component.
|
| constexpr void | normalize () |
| | Normalize the quaternion in place.
|
| constexpr void | conjugate () |
| | Conjugate the quaternion in place.
|
| constexpr void | invert () |
| | Invert the quaternion in place.
|
| constexpr AQuaternion< T > | operator+ () const |
| | Unary plus operator.
|
| constexpr AQuaternion< T > | operator- () const |
| | Unary minus operator.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator+ (const AQuaternion< U, OtherAccessor > &other) const |
| | AQuaternion-quaternion addition.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr AQuaternion< T, Accessor > & | operator+= (const AQuaternion< U, OtherAccessor > &other) |
| | AQuaternion-quaternion addition.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator- (const AQuaternion< U, OtherAccessor > &other) const |
| | AQuaternion-quaternion subtraction.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr AQuaternion< T, Accessor > & | operator-= (const AQuaternion< U, OtherAccessor > &other) |
| | AQuaternion-quaternion subtraction.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator* (const AQuaternion< U, OtherAccessor > &other) const |
| | AQuaternion-quaternion multiplication.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr AQuaternion< T, Accessor > & | operator*= (const AQuaternion< U, OtherAccessor > &other) |
| | AQuaternion-quaternion multiplication.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator* (const AVector3< U, OtherAccessor > &vec) const |
| | AQuaternion-vector multiplication (same as R * v).
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator* (const AMatrix3< U, OtherAccessor > &mat) const |
| | AQuaternion-matrix multiplication.
|
| template<typename U> |
| constexpr auto | operator* (const U &scalar) const |
| | AQuaternion-scalar multiplication.
|
| template<typename U> |
| constexpr AQuaternion< T, Accessor > & | operator*= (const U &scalar) |
| | Self-scalar multiplication.
|
| template<typename U> |
| constexpr auto | operator/ (const U &scalar) const |
| | AQuaternion-scalar division.
|
| template<typename U> |
| constexpr AQuaternion< T, Accessor > & | operator/= (const U &scalar) |
| | Self-scalar division.
|
template<typename T, ValidAccessor< T > Accessor>
class mundy::AQuaternion< T, Accessor >
- Template Parameters
-
| T | The type of the entries. |
| Accessor | The type of the accessor. |
This class is designed to be used with Kokkos. It is a simple quaternion with arithmetic entries. It is templated on the type of the entries and Accessor type. See Accessor.hpp for more details on the Accessor type requirements.
The goal of AQuaternion is to be a lightweight class that can be used with Kokkos to perform mathematical operations on vectors in R3. It does not own the data, but rather it is templated on an Accessor type that provides access to the underlying data. This allows us to use AQuaternion with Kokkos Views, raw pointers, or any other type that meets the ValidAccessor requirements without copying the data. This is especially important for GPU-compatible code. The underlying data is stored in Eigen's coefficient order (x, y, z, w), even though the semantic quaternion constructor and setters accept values in (w, x, y, z) order.
Quaternions can be constructed by passing an accessor to the constructor. However, if the accessor has a 4-argument constructor, then the AQuaternion can also be constructed by passing the elements directly to the constructor. Similarly, if the accessor has an initializer list constructor, then the AQuaternion can be constructed by passing an initializer list to the constructor. This is a convenience feature which makes working with the default accessor (Array<T, 4>) easier. For example, the following are all valid ways to construct an AQuaternion:
quat4.
set(1.0, 2.0, 3.0, 4.0);
double data[4] = {2.0, 3.0, 4.0, 1.0};
AQuaternion class with floating point entries (an integer-valued quaternion doesn't make much sense).
Definition Quaternion.hpp:137
constexpr void set(const T &w, const T &x, const T &y, const T &z)
Set all elements of the quaternion.
Definition Quaternion.hpp:417
friend class AQuaternion
Definition Quaternion.hpp:634
constexpr decltype(auto) data()
Get the internal data accessor.
Definition Quaternion.hpp:370
A simplistic array type with a fixed size and type.
Definition Array.hpp:44
- Note
- Accessors may be owning or non-owning, that is irrelevant to the AQuaternion class; however, these accessors should be lightweight such that they can be copied around without much overhead. Furthermore, the lifetime of the data underlying the accessor should be as long as the AQuaternion that use it.