mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
[wpimath] Add affine transformation constructors and getters to geometry API (#7430)
Fixes #7429.
This commit is contained in:
@@ -308,6 +308,23 @@ class ct_matrix {
|
||||
(*this)(0) * rhs(1) - rhs(0) * (*this)(1)}};
|
||||
}
|
||||
|
||||
/**
|
||||
* Constexpr version of Eigen's 2x2 matrix determinant member function.
|
||||
*
|
||||
* @return Determinant of matrix.
|
||||
*/
|
||||
constexpr Scalar determinant() const
|
||||
requires(Rows == 2 && Cols == 2)
|
||||
{
|
||||
// |a b|
|
||||
// |c d| = ad - bc
|
||||
Scalar a = (*this)(0, 0);
|
||||
Scalar b = (*this)(0, 1);
|
||||
Scalar c = (*this)(1, 0);
|
||||
Scalar d = (*this)(1, 1);
|
||||
return a * d - b * c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constexpr version of Eigen's 3x3 matrix determinant member function.
|
||||
*
|
||||
@@ -364,7 +381,9 @@ using ct_vector = ct_matrix<Scalar, Rows, 1>;
|
||||
template <typename Scalar, int Cols>
|
||||
using ct_row_vector = ct_matrix<Scalar, 1, Cols>;
|
||||
|
||||
using ct_matrix2d = ct_matrix<double, 2, 2>;
|
||||
using ct_matrix3d = ct_matrix<double, 3, 3>;
|
||||
using ct_vector2d = ct_vector<double, 2>;
|
||||
using ct_vector3d = ct_vector<double, 3>;
|
||||
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user