g3 works, but is slow.

This commit is contained in:
Yggdrasil75
2025-12-02 12:11:25 -05:00
parent b3f796ce01
commit ccfac21758
5 changed files with 882 additions and 17 deletions

View File

@@ -294,11 +294,38 @@ public:
float sinA = std::sin(angle);
return Vec3(x * cosA - y * sinA, x * sinA + y * cosA, z);
}
float angle() const {
float r = length();
if (r == 0) return 0;
float θ = std::acos(z / r);
return θ;
}
float azimuth() const {
float φ = std::atan2(y, x);
return φ;
}
std::pair<float, float> sphericalAngles() const {
float r = length();
if (r == 0) return {0, 0};
float θ = std::acos(z / r);
float φ = std::atan2(y, x);
return {θ, φ};
}
float angleTo(const Vec3& other) const {
return std::acos(this->dot(other) / (this->length() * other.length()));
}
float directionTo(const Vec3& other) const {
Vec3 direction = other - *this;
return direction.angleTo(other);
}
float& operator[](int index) {
return (&x)[index];
}