21quat
slerp(
const quat& q1,
const quat& q2,
scalar t);
27vec3
rotate(quat
const& q, vec3
const& v);
41 quat(
const __m128& rhs);
44 void operator=(
const __m128& rhs);
51 void load(
const scalar* ptr);
53 void loadu(
const scalar* ptr);
55 void store(
scalar* ptr)
const;
57 void storeu(
scalar* ptr)
const;
59 void stream(
scalar* ptr)
const;
71 void set(
vec4 const &f4);
90 this->
vec = _mm_setr_ps(0, 0, 0, 1);
99 this->
vec = _mm_setr_ps(
x,
y,
z,
w);
136 return _mm_movemask_ps(_mm_cmpeq_ps(this->
vec, rhs.
vec)) == 0x0f;
145 return _mm_movemask_ps(_mm_cmpeq_ps(this->
vec, rhs.
vec)) != 0x0f;
155 this->
vec = _mm_load_ps(ptr);
165 this->
vec = _mm_loadu_ps(ptr);
175 _mm_store_ps(ptr, this->
vec);
185 _mm_storeu_ps(ptr, this->
vec);
233 this->
vec = _mm_setr_ps(
x,
y,
z,
w);
251 const quat id(0, 0, 0, 1);
261 return _mm_cvtss_f32(_mm_sqrt_ss(_mm_dp_ps(q.
vec, q.
vec, 0xF1)));
270 return _mm_cvtss_f32(_mm_dp_ps(q.
vec, q.
vec, 0xF1));
317 const __m128 con = { -1.0f, -1.0f, -1.0f, 1.0f };
318 quat qq(_mm_mul_ps(q.
vec, con));
328 return _mm_cvtss_f32(_mm_dp_ps(q0.
vec, q1.
vec, 0xF1));
342 f *= sintheta / theta;
354 return quat(_mm_setr_ps(0.0f, 0.0f, 0.0f, 1.0f));
367 __m128 temp = _mm_set1_ps(1.0f / len);
368 con.
vec = _mm_mul_ps(con.
vec, temp);
371 return quat(0.0f, 0.0f, 0.0f, 0.0f);
385 scalar aisina = a * isina;
388 vec3 mul(aisina, aisina, aisina);
393 ret.
set(0.0f, 0.0f, 0.0f, 0.0f);
404 static const __m128 controlWZYX = _mm_setr_ps(1, -1, 1, -1);
405 static const __m128 controlZWXY = _mm_setr_ps(1, 1, -1, -1);
406 static const __m128 controlYXWZ = _mm_setr_ps(-1, 1, 1, -1);
407 __m128 res = _mm_shuffle_ps(q1.
vec, q1.
vec, _MM_SHUFFLE(3, 3, 3, 3));
408 __m128 q1x = _mm_shuffle_ps(q1.
vec, q1.
vec, _MM_SHUFFLE(0, 0, 0, 0));
409 __m128 q1y = _mm_shuffle_ps(q1.
vec, q1.
vec, _MM_SHUFFLE(1, 1, 1, 1));
410 __m128 q1z = _mm_shuffle_ps(q1.
vec, q1.
vec, _MM_SHUFFLE(2, 2, 2, 2));
412 res = _mm_mul_ps(res, q0.
vec);
413 __m128 q0shuffle = q0.
vec;
414 q0shuffle = _mm_shuffle_ps(q0shuffle, q0shuffle, _MM_SHUFFLE(0, 1, 2, 3));
416 q1x = _mm_mul_ps(q1x, q0shuffle);
417 q0shuffle = _mm_shuffle_ps(q0shuffle, q0shuffle, _MM_SHUFFLE(2, 3, 0, 1));
418 res =
fmadd(q1x, controlWZYX, res);
420 q1y = _mm_mul_ps(q1y, q0shuffle);
421 q0shuffle = _mm_shuffle_ps(q0shuffle, q0shuffle, _MM_SHUFFLE(0, 1, 2, 3));
422 q1y = _mm_mul_ps(q1y, controlZWXY);
424 q1z = _mm_mul_ps(q1z, q0shuffle);
426 q1y =
fmadd(q1z, controlYXWZ, q1y);
427 return _mm_add_ps(res, q1y);
436 return quat(_mm_div_ps(q.
vec, _mm_sqrt_ps(_mm_dp_ps(q.
vec, q.
vec, 0xff))));
453 b = _mm_or_ps(b,
_id_w);
454 return _mm_mul_ps(b, _mm_set_ps(cosangle, sinangle, sinangle, sinangle));
467 float qdot =
dot(q1, q2);
472 to = _mm_mul_ps(q2.
vec, _mm_set_ps1(-1.0f));
490 __m128 s0 = _mm_set_ps1(sin_omega_t);
491 __m128 s1 = _mm_set_ps1(sin_angle_t);
492 __m128 sin_div = _mm_set_ps1(1.0f / sin_angle);
493 return _mm_mul_ps(_mm_add_ps(_mm_mul_ps(q1.
vec, s0), _mm_mul_ps(to, s1)), sin_div);
498 float scale0 = 1.0f - t;
500 __m128 s0 = _mm_set_ps1(scale0);
501 __m128 s1 = _mm_set_ps1(scale1);
503 return _mm_add_ps(_mm_mul_ps(q1.
vec, s0), _mm_mul_ps(to, s1));
513 n_error(
"FIXME: not implemented");
551 vec3 const rv = v * q.
w;
552 vec3 const rot =
cross(i, qxv + rv) * 2.0f;
void __cdecl n_error(const char *msg,...)
This function is called when a serious situation is encountered which requires abortion of the applic...
Definition debug.cc:138
#define n_assert2(exp, msg)
Definition debug.h:51
Different curves.
Definition angularpfeedbackloop.h:17
__forceinline vec3 cross(const vec3 &v0, const vec3 &v1)
Definition vec3.h:417
vec3 to_euler(const quat &q)
Definition quat.cc:84
__forceinline quat barycentric(const quat &q0, const quat &q1, const quat &q2, scalar f, scalar g)
Definition quat.h:295
__forceinline float undenormalize(scalar s)
Returns 0 if scalar is denormal.
Definition scalar.h:644
quat rotationmatrix(const mat4 &m)
Definition quat.cc:17
__forceinline scalar length3(const vec4 &v)
Definition vec4.h:395
__forceinline quat conjugate(const quat &q)
Definition quat.h:315
__forceinline scalar angle(const vec3 &v0, const vec3 &v1)
Definition vec3.h:508
__forceinline quat identity()
Definition quat.h:352
quat slerp(const quat &q1, const quat &q2, scalar t)
quat slerp TODO: rewrite using sse/avx
Definition quat.h:463
__forceinline scalar length(const quat &q)
Definition quat.h:259
__forceinline scalar lengthsq(const quat &q)
Definition quat.h:268
__forceinline scalar dot(const plane &p, const vec4 &v1)
Definition plane.h:246
__forceinline plane normalize(const plane &p)
Definition plane.h:255
__forceinline float clamp(float val, float minVal, float maxVal)
Float clamping.
Definition scalar.h:487
__forceinline quat quatExp(const quat &q)
Definition quat.h:335
__forceinline __m128 mul(__m128 a, __m128 b)
Definition sse.h:64
static const __m128 _id_w
Definition vec3.h:32
__forceinline void to_axisangle(const quat &q, vec4 &outAxis, scalar &outAngle)
Definition quat.h:532
__forceinline bool isidentity(const mat4 &m)
Definition mat4.h:372
float scalar
Definition scalar.h:45
__forceinline void squadsetup(const quat &q0, const quat &q1, const quat &q2, const quat &q3, quat &aOut, quat &bOut, quat &cOut)
Definition quat.h:511
half operator*(half one, half two)
Definition half.h:123
quat quatyawpitchroll(scalar y, scalar x, scalar z)
Definition quat.cc:63
__forceinline quat squad(const quat &q1, const quat &a, const quat &b, const quat &c, scalar t)
Definition quat.h:523
__forceinline scalar cos(scalar x)
Definition scalar.h:191
__forceinline scalar acos(scalar x)
Definition scalar.h:218
__forceinline quat quatUndenormalize(const quat &q)
Definition quat.h:277
__forceinline bool nearequal(const point &v0, const point &v1, float epsilon)
Definition point.h:485
static const __m128 _mask_xyz
Definition vec3.h:37
__forceinline scalar sin(scalar x)
Definition scalar.h:182
__forceinline quat ln(const quat &q)
Definition quat.h:378
vec3 rotate(quat const &q, vec3 const &v)
Rotate a vector by a quaternion.
Definition quat.h:547
__forceinline quat rotationquataxis(const vec3 &axis, scalar angle)
quat from rotation axis + angle.
Definition quat.h:444
quat from_euler(const vec3 &v)
Definition quat.cc:100
__forceinline __m128 fmadd(__m128 a, __m128 b, __m128 c)
Fused multiply-add operation, (a * b) + c.
Definition sse.h:22
__forceinline mat4 inverse(const mat4 &m)
Definition mat4.h:429
Nebula's scalar datatype.
A 4x4 single point precision float matrix.
Definition mat4.h:49
A quaternion is usually used to represent an orientation in 3D space.
Definition quat.h:30
float y
Definition quat.h:78
quat(quat const &)=default
default copy constructor
vec3 y_axis() const
get the y axis of the cartesian coordinate system that this quaternion represents
Definition quat.h:211
quat()
default constructor
Definition quat.h:88
void stream(scalar *ptr) const
stream content to 16-byte-aligned memory circumventing the write-cache
Definition quat.h:192
void operator=(const __m128 &rhs)
assign __m128
Definition quat.h:125
bool operator==(const quat &rhs) const
equality operator
Definition quat.h:134
void load(const scalar *ptr)
load content from 16-byte-aligned memory
Definition quat.h:153
bool operator!=(const quat &rhs) const
inequality operator
Definition quat.h:143
void storeu(scalar *ptr) const
write content to unaligned memory through the write cache
Definition quat.h:183
void loadu(const scalar *ptr)
load content from unaligned memory
Definition quat.h:163
void store(scalar *ptr) const
write content to 16-byte-aligned memory through the write cache
Definition quat.h:173
__m128 vec
Definition quat.h:80
void set(scalar x, scalar y, scalar z, scalar w)
set content
Definition quat.h:231
float z
Definition quat.h:78
float w
Definition quat.h:78
float x
Definition quat.h:78
vec3 x_axis() const
get the x axis of the cartesian coordinate system that this quaternion represents
Definition quat.h:201
vec3 z_axis() const
get the z axis of the cartesian coordinate system that this quaternion represents
Definition quat.h:221
A 3D vector.
Definition vec3.h:40
__m128 vec
Definition vec3.h:96
A 4D vector.
Definition vec4.h:24
__m128 vec
Definition vec4.h:95
float w
Definition vec4.h:93
bool operator==(const TiXmlString &a, const TiXmlString &b)
Definition tinystr.h:272
bool operator!=(const TiXmlString &a, const TiXmlString &b)
Definition tinystr.h:282
#define NEBULA_ALIGN16
Definition types.h:154