pushing some additional features

This commit is contained in:
yggdrasil75
2026-01-18 20:44:30 -05:00
parent 81af30d4c6
commit b820c89bd0
5 changed files with 735 additions and 27 deletions

View File

@@ -312,6 +312,11 @@ public:
float aspect() {
return static_cast<float>(x) / static_cast<float>(y);
}
Vec2<float> toFloat() {
return Vec2<float>(static_cast<float>(x), static_cast<float>(y));
}
};
template<typename T>

View File

@@ -454,6 +454,29 @@ public:
return std::hash<float>()(v.x) ^ (std::hash<float>()(v.y) << 1) ^ (std::hash<float>()(v.z) << 2);
}
};
Vec2<T> toLatLon() const {
float r = length();
if (r == 0) return Vec2<T>(0, 0);
float θ = std::acos(z / r);
float lat = static_cast<T>(M_PI/2.0 - θ);
float lon = static_cast<T>(std::atan2(y, x));
return Vec2<T>(lat, lon);
}
Vec2<T> toLatLon(const Vec3& center) const {
Vec3 relative = *this - center;
return relative.toLatLon();
}
T toElevation() const {
return length();
}
T toElevation(const Vec3& center) const {
return distance(center);
}
};
using Vec3f = Vec3<float>;