This commit is contained in:
Fire-Head
2020-12-19 22:33:17 +03:00
98 changed files with 2783 additions and 2201 deletions

View File

@ -12,6 +12,11 @@ public:
float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; }
void Normalise(void);
void Multiply(const CQuaternion &q1, const CQuaternion &q2);
void Invert(void){ // Conjugate would have been a better name
x = -x;
y = -y;
z = -z;
}
const CQuaternion &operator+=(CQuaternion const &right) {
x += right.x;

View File

@ -1,23 +1,22 @@
#pragma once
class CVector
class CVector : public RwV3d
{
public:
float x, y, z;
CVector(void) {}
CVector(float x, float y, float z) : x(x), y(y), z(z) {}
#ifdef RWCORE_H
CVector(const RwV3d &v) : x(v.x), y(v.y), z(v.z) {}
CVector(float x, float y, float z)
{
this->x = x;
this->y = y;
this->z = z;
}
operator RwV3d (void) const {
RwV3d vecRw = { this->x, this->y, this->z };
return vecRw;
CVector(const RwV3d &v)
{
x = v.x;
y = v.y;
z = v.z;
}
operator RwV3d *(void) {
return (RwV3d*)this;
}
#endif
// (0,1,0) means no rotation. So get right vector and its atan
float Heading(void) const { return Atan2(-x, y); }
float Magnitude(void) const { return Sqrt(x*x + y*y + z*z); }

View File

@ -8,18 +8,7 @@ public:
CVuVector(float x, float y, float z) : CVector(x, y, z) {}
CVuVector(float x, float y, float z, float w) : CVector(x, y, z), w(w) {}
CVuVector(const CVector &v) : CVector(v.x, v.y, v.z) {}
#ifdef RWCORE_H
CVuVector(const RwV3d &v) : CVector(v.x, v.y, v.z) {}
operator RwV3d (void) const {
RwV3d vecRw = { this->x, this->y, this->z };
return vecRw;
}
operator RwV3d *(void) {
return (RwV3d*)this;
}
#endif
CVuVector(const RwV3d &v) : CVector(v) {}
/*
void Normalise(void) {
float sq = MagnitudeSqr();