29[[nodiscard]]
inline T
dot(
const QuaternionBase<T> &a,
const QuaternionBase<T> &
b);
36template<
typename T> [[nodiscard]] QuaternionBase<T>
pow(
const QuaternionBase<T> &q,
const T &y);
43template<
typename T> [[nodiscard]]
inline QuaternionBase<T>
conjugate(
const QuaternionBase<T> &a);
49[[nodiscard]]
inline QuaternionBase<T>
canonicalize(
const QuaternionBase<T> &q);
56template<
typename T> [[nodiscard]]
inline QuaternionBase<T>
invert(
const QuaternionBase<T> &q);
64[[nodiscard]]
inline QuaternionBase<T>
invert_normalized(
const QuaternionBase<T> &q);
70template<
typename T> [[nodiscard]]
inline QuaternionBase<T>
normalize(
const QuaternionBase<T> &q);
80[[nodiscard]]
inline QuaternionBase<T>
interpolate(
const QuaternionBase<T> &a,
81 const QuaternionBase<T> &
b,
94[[nodiscard]]
inline VecBase<T, 3>
transform_point(
const QuaternionBase<T> &q,
95 const VecBase<T, 3> &
v);
108 return q.
w ==
T(0) && q.
x ==
T(0) && q.
y ==
T(0) && q.
z ==
T(0);
117 const T epsilon =
T(0))
128 const T test_unit = q.
x * q.
x + q.
y * q.
y + q.
z * q.
z + q.
w * q.
w;
167 input_vec[0], input_vec.
yzw()[axis.as_int()]);
170 twist[axis.as_int() + 1] = half_angle.
sin();
199 return a.w *
b.w + a.x *
b.x + a.y *
b.y + a.z *
b.z;
223 return {a.
w, -a.x, -a.y, -a.z};
229 return (q.
w < T(0)) ? -q : q;
273 const T
eps =
T(1
e-4);
319 return {
R.x,
R.y,
R.z};
323 S.
w = -q.
x *
v.x - q.
y *
v.y - q.
z *
v.z;
324 S.
x = q.
w *
v.x + q.
y *
v.z - q.
z *
v.y;
325 S.
y = q.
w *
v.y + q.
z *
v.x - q.
x *
v.z;
326 S.
z = q.
w *
v.z + q.
x *
v.y - q.
y *
v.x;
330 R.x = S.
w * -q.
x + S.
x * q.
w - S.
y * q.
z + S.
z * q.
y;
331 R.y = S.
w * -q.
y + S.
y * q.
w - S.
z * q.
x + S.
x * q.
z;
332 R.z = S.
w * -q.
z + S.
z * q.
w - S.
x * q.
y + S.
y * q.
x;
348 : quat(non_dual), trans(dual), scale_weight(0), quat_weight(1)
357 : quat(non_dual), trans(dual), scale(scale_mat), scale_weight(1), quat_weight(1)
371 if (
dot(a.quat,
b.quat) < 0) {
372 a.
quat.w -=
b.quat.w;
373 a.quat.x -=
b.quat.x;
374 a.quat.y -=
b.quat.y;
375 a.quat.z -=
b.quat.z;
377 a.trans.w -=
b.trans.w;
378 a.trans.x -=
b.trans.x;
379 a.trans.y -=
b.trans.y;
380 a.trans.z -=
b.trans.z;
383 a.quat.w +=
b.quat.w;
384 a.quat.x +=
b.quat.x;
385 a.quat.y +=
b.quat.y;
386 a.quat.z +=
b.quat.z;
388 a.trans.w +=
b.trans.w;
389 a.trans.x +=
b.trans.x;
390 a.trans.y +=
b.trans.y;
391 a.trans.z +=
b.trans.z;
394 a.quat_weight +=
b.quat_weight;
396 if (
b.scale_weight > T(0)) {
397 if (a.scale_weight > T(0)) {
400 a.scale_weight +=
b.scale_weight;
405 a.scale_weight =
b.scale_weight;
449 if (norm_weighted ==
T(0)) {
454 const T inv_norm_weighted =
T(1) / norm_weighted;
457 dq.
quat = dq.
quat * inv_norm_weighted;
466 if (missing_uniform_scale >
T(0)) {
467 dq.
scale[0][0] += missing_uniform_scale;
468 dq.
scale[1][1] += missing_uniform_scale;
469 dq.
scale[2][2] += missing_uniform_scale;
470 dq.
scale[3][3] += missing_uniform_scale;
503 t[0] =
T(2) * (-we * x0 + xe * w0 - ye * z0 + ze * y0);
504 t[1] =
T(2) * (-we * y0 + xe * z0 + ye * w0 - ze * x0);
505 t[2] =
T(2) * (-we * z0 - xe * y0 + ye * x0 + ze * w0);
508 M[0][0] = (w0 * w0) + (x0 * x0) - (y0 * y0) - (z0 * z0);
509 M[0][1] =
T(2) * ((x0 * y0) + (w0 * z0));
510 M[0][2] =
T(2) * ((x0 * z0) - (w0 * y0));
512 M[1][0] =
T(2) * ((x0 * y0) - (w0 * z0));
513 M[1][1] = (w0 * w0) + (y0 * y0) - (x0 * x0) - (z0 * z0);
514 M[1][2] =
T(2) * ((y0 * z0) + (w0 * x0));
516 M[2][1] =
T(2) * ((y0 * z0) - (w0 * x0));
517 M[2][2] = (w0 * w0) + (z0 * z0) - (x0 * x0) - (y0 * y0);
518 M[2][0] =
T(2) * ((x0 * z0) + (w0 * y0));
530 if (r_crazy_space_mat !=
nullptr) {
535 *r_crazy_space_mat =
M;
569 Mat4T baseRS = mat * basemat;
576 const Mat4T baseinv =
invert(basemat);
582 baseR.location() = baseRS.location();
586 const Mat4T S =
invert(baseR) * baseRS;
588 scale = basemat * S * baseinv;
599 const Vec3T &t =
R.location().xyz();
601 d.
w =
T(-0.5) * (+t.x * q.
x + t.y * q.
y + t.z * q.
z);
602 d.
x =
T(+0.5) * (+t.x * q.
w + t.y * q.
z - t.z * q.
y);
603 d.
y =
T(+0.5) * (-t.x * q.
z + t.y * q.
w + t.z * q.
x);
604 d.
z =
T(+0.5) * (+t.x * q.
y - t.y * q.
x + t.z * q.
w);
623template<
typename T,
typename AngleT = AngleRadian>
629 T cos_half_angle = quat.
w;
632 if (sin_half_angle <
T(0.0005)) {
640 axis /= sin_half_angle;
643 AngleT angle = AngleT(cos_half_angle, sin_half_angle) * 2;
658 Mat3T unit_mat = from_rotation<Mat3T>(quat);
659 return to_euler<T>(unit_mat);
666 Mat3T unit_mat = from_rotation<Mat3T>(quat);
667 return to_euler<T>(unit_mat, order);
677template<
typename T,
typename AngleT>
678QuaternionBase<T> to_quaternion(
const AxisAngleBase<T, AngleT> &axis_angle);
697 return axis_angle.axis() * axis_angle.angle().radian();
#define IN_RANGE_INCL(a, b, c)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
local_group_size(16, 16) .push_constant(Type b
QuaternionBase< T > conjugate(const QuaternionBase< T > &a)
T length_squared(const VecBase< T, Size > &a)
T cos(const AngleRadianBase< T > &a)
T pow(const T &x, const T &power)
bool is_normalized(const DualQuaternionBase< T > &dq)
QuaternionBase< T > to_quaternion(const AxisAngleBase< T, AngleT > &axis_angle)
MatBase< T, NumCol, NumRow > scale(const MatBase< T, NumCol, NumRow > &mat, const VectorT &scale)
bool is_orthonormal(const MatT &mat)
T length(const VecBase< T, Size > &a)
QuaternionBase< T > normalize_and_get_length(const QuaternionBase< T > &q, T &out_length)
bool is_unit_scale(const MatBase< T, NumCol, NumRow > &m)
bool is_negative(const MatBase< T, Size, Size > &mat)
CartesianBasis invert(const CartesianBasis &basis)
T interpolate(const T &a, const T &b, const FactorT &t)
QuaternionBase< T > invert_normalized(const QuaternionBase< T > &q)
AxisAngleBase< T, AngleT > to_axis_angle(const EulerXYZBase< T > &euler)
VecBase< T, 3 > to_scale(const MatBase< T, NumCol, NumRow > &mat)
QuaternionBase< T > canonicalize(const QuaternionBase< T > &q)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
bool is_equal(const MatBase< T, NumCol, NumRow > &a, const MatBase< T, NumCol, NumRow > &b, const T epsilon=T(0))
T sin(const AngleRadianBase< T > &a)
MatT orthogonalize(const MatT &mat, const Axis axis)
VecBase< T, 2 > interpolate_dot_slerp(const T t, const T cosom)
MatT from_rotation(const RotationT &rotation)
DualQuaternionBase< T > to_dual_quaternion(const MatBase< T, 4, 4 > &mat, const MatBase< T, 4, 4 > &basemat)
Euler3Base< T > to_euler(const AxisAngleBase< T, AngleT > &axis_angle, EulerOrder order)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
VecBase< T, 3 > yzw() const
static AngleCartesianBase from_point(const T &x, const T &y)
const vec3_type & axis() const
DualQuaternionBase & operator*=(const T &t)
DualQuaternionBase()=delete
QuaternionBase< T > trans
DualQuaternionBase & operator+=(const DualQuaternionBase &b)
static DualQuaternionBase identity()
const VecBase< T, 3 > & imaginary_part() const
QuaternionBase swing(const Axis axis) const
AngleRadianBase< T > twist_angle(const Axis axis) const
static QuaternionBase identity()
QuaternionBase twist(const Axis axis) const
QuaternionBase wrapped_around(const QuaternionBase &reference) const
ccl_device_inline int abs(int x)
CCL_NAMESPACE_BEGIN struct Window V