Fixed rsQuaternionAdd() implementation
Bug: 26272685
We use float4 to represent a quaternion, in which
a float4 q = (x,y,z,w) represents quaternion
wi + xj + yk + zl.
According to Wikipedia and Wolfram, the addition of two quaternions
q and r should be defined as the following
(q.w+r.w)i + (q.x+r.x)j + (q.y+q.y)k + (q.z+r.z)l,
using the above representation of quaternions.
https://en.wikipedia.org/wiki/Quaternion
http://mathworld.wolfram.com/Quaternion.html
Change-Id: I07837b266f51b664bed2dc50b9ff71ba375f5aaf
diff --git a/scriptc/rs_quaternion.rsh b/scriptc/rs_quaternion.rsh
index 524eeb0..c7c32e2 100644
--- a/scriptc/rs_quaternion.rsh
+++ b/scriptc/rs_quaternion.rsh
@@ -36,10 +36,10 @@
*/
static inline void __attribute__((overloadable))
rsQuaternionAdd(rs_quaternion* q, const rs_quaternion* rhs) {
- q->w *= rhs->w;
- q->x *= rhs->x;
- q->y *= rhs->y;
- q->z *= rhs->z;
+ q->w += rhs->w;
+ q->x += rhs->x;
+ q->y += rhs->y;
+ q->z += rhs->z;
}
/*