add quaternion

This commit is contained in:
Nishi 2026-06-06 01:28:10 +09:00
commit 748d52c9c9
3 changed files with 20 additions and 2 deletions

View file

@ -27,6 +27,16 @@ namespace fishbone {
float y;
float z;
};
struct Quaternion {
struct fishbone::Quaternion operator+(struct fishbone::Quaternion q) const;
struct fishbone::Quaternion operator-(struct fishbone::Quaternion q) const;
float w;
float x;
float y;
float z;
};
}; // namespace fishbone
#endif

View file

@ -38,8 +38,8 @@ float r = 0;
bool fishbone::Client::step() {
this->renderer->prepare();
m->draw((struct fishbone::Vector3){0, 0, 0}, (struct fishbone::Vector3){0, r, 0});
r++;
m->draw((struct fishbone::Vector3){0, 0, 0}, (struct fishbone::Vector3){r, r, r});
r += 30.0 / 60;
this->window->swapBuffer();

View file

@ -54,3 +54,11 @@ struct fishbone::Vector3 fishbone::Vector3::normalize() {
return {this->x * l, this->y * l, this->z * l};
}
struct fishbone::Quaternion fishbone::Quaternion::operator+(struct fishbone::Quaternion q) const {
return {this->w + q.w, this->x + q.x, this->y + q.y, this->z + q.z};
}
struct fishbone::Quaternion fishbone::Quaternion::operator-(struct fishbone::Quaternion q) const {
return {this->w - q.w, this->x - q.x, this->y - q.y, this->z - q.z};
}