mirror of https://github.com/AxioDL/zeus.git
Move some quaternion functions in-header
This commit is contained in:
parent
c81eb93b6d
commit
48073c783b
|
@ -67,31 +67,46 @@ public:
|
||||||
|
|
||||||
void fromVector3f(const CVector3f& vec);
|
void fromVector3f(const CVector3f& vec);
|
||||||
|
|
||||||
CQuaternion& operator=(const CQuaternion& q);
|
CQuaternion& operator=(const CQuaternion& q) {
|
||||||
|
mSimd = q.mSimd;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
CQuaternion operator+(const CQuaternion& q) const;
|
CQuaternion operator+(const CQuaternion& q) const { return mSimd + q.mSimd; }
|
||||||
|
|
||||||
CQuaternion operator-(const CQuaternion& q) const;
|
CQuaternion operator-(const CQuaternion& q) const { return mSimd - q.mSimd; }
|
||||||
|
|
||||||
CQuaternion operator*(const CQuaternion& q) const;
|
CQuaternion operator*(const CQuaternion& q) const;
|
||||||
|
|
||||||
CQuaternion operator/(const CQuaternion& q) const;
|
CQuaternion operator/(const CQuaternion& q) const;
|
||||||
|
|
||||||
CQuaternion operator*(float scale) const;
|
CQuaternion operator*(float scale) const { return mSimd * simd<float>(scale); }
|
||||||
|
|
||||||
CQuaternion operator/(float scale) const;
|
CQuaternion operator/(float scale) const { return mSimd / simd<float>(scale); }
|
||||||
|
|
||||||
CQuaternion operator-() const;
|
CQuaternion operator-() const { return -mSimd; }
|
||||||
|
|
||||||
const CQuaternion& operator+=(const CQuaternion& q);
|
const CQuaternion& operator+=(const CQuaternion& q) {
|
||||||
|
mSimd += q.mSimd;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
const CQuaternion& operator-=(const CQuaternion& q);
|
const CQuaternion& operator-=(const CQuaternion& q) {
|
||||||
|
mSimd -= q.mSimd;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
const CQuaternion& operator*=(const CQuaternion& q);
|
const CQuaternion& operator*=(const CQuaternion& q);
|
||||||
|
|
||||||
const CQuaternion& operator*=(float scale);
|
const CQuaternion& operator*=(float scale) {
|
||||||
|
mSimd *= simd<float>(scale);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
const CQuaternion& operator/=(float scale);
|
const CQuaternion& operator/=(float scale) {
|
||||||
|
mSimd /= simd<float>(scale);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
float magnitude() const { return std::sqrt(magSquared()); }
|
float magnitude() const { return std::sqrt(magSquared()); }
|
||||||
|
|
||||||
|
@ -249,9 +264,12 @@ public:
|
||||||
|
|
||||||
CNUQuaternion operator*(const CNUQuaternion& q) const;
|
CNUQuaternion operator*(const CNUQuaternion& q) const;
|
||||||
|
|
||||||
CNUQuaternion operator*(float f) const;
|
CNUQuaternion operator*(float f) const { return mSimd * simd<float>(f); }
|
||||||
|
|
||||||
const CNUQuaternion& operator+=(const CNUQuaternion& q);
|
const CNUQuaternion& operator+=(const CNUQuaternion& q) {
|
||||||
|
mSimd += q.mSimd;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
zeus::simd<float>::reference operator[](size_t idx) {
|
zeus::simd<float>::reference operator[](size_t idx) {
|
||||||
assert(idx < 4);
|
assert(idx < 4);
|
||||||
|
|
|
@ -76,15 +76,6 @@ void CQuaternion::fromVector3f(const CVector3f& vec) {
|
||||||
mSimd.copy_from(f);
|
mSimd.copy_from(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
CQuaternion& CQuaternion::operator=(const CQuaternion& q) {
|
|
||||||
mSimd = q.mSimd;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CQuaternion CQuaternion::operator+(const CQuaternion& q) const { return mSimd + q.mSimd; }
|
|
||||||
|
|
||||||
CQuaternion CQuaternion::operator-(const CQuaternion& q) const { return mSimd - q.mSimd; }
|
|
||||||
|
|
||||||
CQuaternion CQuaternion::operator*(const CQuaternion& q) const {
|
CQuaternion CQuaternion::operator*(const CQuaternion& q) const {
|
||||||
return CQuaternion(w() * q.w() - CVector3f(x(), y(), z()).dot({q.x(), q.y(), q.z()}),
|
return CQuaternion(w() * q.w() - CVector3f(x(), y(), z()).dot({q.x(), q.y(), q.z()}),
|
||||||
y() * q.z() - z() * q.y() + w() * q.x() + x() * q.w(),
|
y() * q.z() - z() * q.y() + w() * q.x() + x() * q.w(),
|
||||||
|
@ -105,29 +96,6 @@ CQuaternion CQuaternion::operator/(const CQuaternion& q) const {
|
||||||
return *this * p;
|
return *this * p;
|
||||||
}
|
}
|
||||||
|
|
||||||
CQuaternion CQuaternion::operator*(float scale) const { return mSimd * simd<float>(scale); }
|
|
||||||
|
|
||||||
CNUQuaternion CNUQuaternion::operator*(float scale) const { return mSimd * simd<float>(scale); }
|
|
||||||
|
|
||||||
CQuaternion CQuaternion::operator/(float scale) const { return mSimd / simd<float>(scale); }
|
|
||||||
|
|
||||||
CQuaternion CQuaternion::operator-() const { return -mSimd; }
|
|
||||||
|
|
||||||
const CQuaternion& CQuaternion::operator+=(const CQuaternion& q) {
|
|
||||||
mSimd += q.mSimd;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CNUQuaternion& CNUQuaternion::operator+=(const CNUQuaternion& q) {
|
|
||||||
mSimd += q.mSimd;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CQuaternion& CQuaternion::operator-=(const CQuaternion& q) {
|
|
||||||
mSimd -= q.mSimd;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CQuaternion& CQuaternion::operator*=(const CQuaternion& q) {
|
const CQuaternion& CQuaternion::operator*=(const CQuaternion& q) {
|
||||||
CQuaternion orig = *this;
|
CQuaternion orig = *this;
|
||||||
|
|
||||||
|
@ -139,16 +107,6 @@ const CQuaternion& CQuaternion::operator*=(const CQuaternion& q) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CQuaternion& CQuaternion::operator*=(float scale) {
|
|
||||||
mSimd *= simd<float>(scale);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CQuaternion& CQuaternion::operator/=(float scale) {
|
|
||||||
mSimd /= simd<float>(scale);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CQuaternion CQuaternion::log() const {
|
CQuaternion CQuaternion::log() const {
|
||||||
float a = std::acos(w());
|
float a = std::acos(w());
|
||||||
float sina = std::sin(a);
|
float sina = std::sin(a);
|
||||||
|
|
Loading…
Reference in New Issue