mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[wpimath] Prevent CoordinateSystem from accepting left-handed systems (#8750)
This commit is contained in:
@@ -4,10 +4,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gcem.hpp>
|
||||
|
||||
#include "wpi/math/geometry/CoordinateAxis.hpp"
|
||||
#include "wpi/math/geometry/Pose3d.hpp"
|
||||
#include "wpi/math/geometry/Rotation3d.hpp"
|
||||
#include "wpi/math/geometry/Translation3d.hpp"
|
||||
#include "wpi/math/linalg/ct_matrix.hpp"
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
|
||||
namespace wpi::math {
|
||||
@@ -39,6 +42,13 @@ class WPILIB_DLLEXPORT CoordinateSystem {
|
||||
{positiveX.m_axis(1), positiveY.m_axis(1), positiveZ.m_axis(1)},
|
||||
{positiveX.m_axis(2), positiveY.m_axis(2), positiveZ.m_axis(2)}};
|
||||
|
||||
// If determinant is -1, coordinate system is left-handed
|
||||
if (gcem::abs(ct_matrix{R}.determinant() + 1.0) < 1e-9) {
|
||||
throw std::domain_error(
|
||||
"CoordinateSystem requires a right-handed system, but a left-handed "
|
||||
"one was provided");
|
||||
}
|
||||
|
||||
// The change of basis matrix should be a pure rotation. The Rotation3d
|
||||
// constructor will verify this by checking for special orthogonality.
|
||||
m_rotation = Rotation3d{R};
|
||||
|
||||
Reference in New Issue
Block a user