mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 23:13:26 +00:00
Refactors perpendicular vector selection
Simplifies logic for finding a non-zero perpendicular vector by iterating through candidate directions. This improves readability and maintainability.
This commit is contained in:
@@ -134,13 +134,10 @@ namespace omath::collision
|
|||||||
template<class V>
|
template<class V>
|
||||||
static constexpr V any_perp(const V& v)
|
static constexpr V any_perp(const V& v)
|
||||||
{
|
{
|
||||||
// try cross with axes until non-zero
|
for (const auto& dir : {V{1, 0, 0}, {0, 1, 0}, {0, 0, 1}})
|
||||||
V d = v.cross(V{1, 0, 0});
|
if (const auto d = v.cross(dir); !near_zero(d))
|
||||||
if (near_zero(d))
|
return d;
|
||||||
d = v.cross(V{0, 1, 0});
|
std::unreachable();
|
||||||
if (near_zero(d))
|
|
||||||
d = v.cross(V{0, 0, 1});
|
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool handle_line(VectorType& direction)
|
constexpr bool handle_line(VectorType& direction)
|
||||||
|
|||||||
Reference in New Issue
Block a user