diff options
author | quou <quou@disroot.org> | 2025-01-27 21:45:15 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2025-01-27 21:45:15 +1100 |
commit | 78c3bac3c690d48e9e751890c38769c785fadf50 (patch) | |
tree | 40dd73a64187f4d5d73dbfe8c6b3cae477e2ced2 /maths.hpp | |
parent | 7ca709069cc280969b8d71bb19a09b8aeb13b859 (diff) |
perp
Diffstat (limited to 'maths.hpp')
-rw-r--r-- | maths.hpp | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -261,6 +261,13 @@ struct v3 { return v3<T>(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); } + static v3<T> perp(const v3<T>& v) { + v3<T> up((T)0, (T)1, (T)0); + if (mag_sqrd(v - up) < (T)0.1f) + up = v3<T>((T)1, (T)0, (T)0); + return cross(v, up); + } + static T mag_sqrd(const v3<T>& v) { return v3<T>::dot(v, v); } |