45 const Float w = 0.5_f *
sqrt(1._f + m(0, 0) + m(1, 1) + m(2, 2));
46 const Float n = 0.25_f / w;
47 v[
X] = (m(2, 1) - m(1, 2)) * n;
48 v[
Y] = (m(0, 2) - m(2, 0)) * n;
49 v[
Z] = (m(1, 0) - m(0, 1)) * n;
61 return acos(v[
H]) * 2._f;
75 const Vector s = v * (n > 0._f ? 2._f / n : 0._f);
86 Vector(1._f - yy - zz, xy - w[
Z], xz + w[
Y]),
87 Vector(xy + w[
Z], 1._f - xx - zz, yz - w[
X]),
88 Vector(xz - w[
Y], yz + w[
X], 1._f - xx - yy));
Three-dimensional affine matrix.
#define SPH_ASSERT(x,...)
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
INLINE T sqrt(const T f)
Return a squared root of a value.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
INLINE Tuple< TArgs &... > tieToTuple(TArgs &... args)
Creates a tuple of l-value references. Use IGNORE placeholder to omit one or more parameters.
INLINE Tuple< Vector, Float > getNormalizedWithLength(const Vector &v)
Returns normalized vector and length of the input vector as tuple.
INLINE Float getSqrLength(const Vector &v)
BasicVector< Float > Vector
INLINE Vector translation() const
bool isOrthogonal() const
Quaternion representing an axis of rotation and a (half of) rotation angle.
Quat(const Vector &axis, const Float angle)
Creates a quaternion given rotation axis and angle of rotation.
INLINE Vector axis() const
Returns the normalized rotational axis.
INLINE Float angle() const
Returns the angle of rotation (in radians).
AffineMatrix convert() const
Converts the quaternion into a rotation matrix.
Quat(const AffineMatrix &m)
Creates a quaternion given a rotation matrix.
INLINE Float operator[](const Size idx) const
INLINE Float & operator[](const Size idx)