Improved Point.hpp to_2d() and to_3d() templates to accept Eigen expressions
This commit is contained in:
parent
493ada15a5
commit
5cba1e8319
@ -111,11 +111,17 @@ inline double angle(const Eigen::MatrixBase<Derived> &v1, const Eigen::MatrixBas
|
|||||||
return atan2(cross2(v1d, v2d), v1d.dot(v2d));
|
return atan2(cross2(v1d, v2d), v1d.dot(v2d));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, int N, int Options>
|
template<typename Derived>
|
||||||
Eigen::Matrix<T, 2, 1, Eigen::DontAlign> to_2d(const Eigen::MatrixBase<Eigen::Matrix<T, N, 1, Options>> &ptN) { return { ptN.x(), ptN.y() }; }
|
Eigen::Matrix<typename Derived::Scalar, 2, 1, Eigen::DontAlign> to_2d(const Eigen::MatrixBase<Derived> &ptN) {
|
||||||
|
static_assert(Derived::IsVectorAtCompileTime && int(Derived::SizeAtCompileTime) >= 3, "to_2d(): first parameter is not a 3D or higher dimensional vector");
|
||||||
|
return { ptN.x(), ptN.y() };
|
||||||
|
}
|
||||||
|
|
||||||
template<class T, int Options>
|
template<typename Derived>
|
||||||
Eigen::Matrix<T, 3, 1, Eigen::DontAlign> to_3d(const Eigen::MatrixBase<Eigen::Matrix<T, 2, 1, Options>> & pt, const T z) { return { pt.x(), pt.y(), z }; }
|
inline Eigen::Matrix<typename Derived::Scalar, 3, 1, Eigen::DontAlign> to_3d(const Eigen::MatrixBase<Derived> &pt, const typename Derived::Scalar z) {
|
||||||
|
static_assert(Derived::IsVectorAtCompileTime && int(Derived::SizeAtCompileTime) == 2, "to_3d(): first parameter is not a 2D vector");
|
||||||
|
return { pt.x(), pt.y(), z };
|
||||||
|
}
|
||||||
|
|
||||||
inline Vec2d unscale(coord_t x, coord_t y) { return Vec2d(unscale<double>(x), unscale<double>(y)); }
|
inline Vec2d unscale(coord_t x, coord_t y) { return Vec2d(unscale<double>(x), unscale<double>(y)); }
|
||||||
inline Vec2d unscale(const Vec2crd &pt) { return Vec2d(unscale<double>(pt.x()), unscale<double>(pt.y())); }
|
inline Vec2d unscale(const Vec2crd &pt) { return Vec2d(unscale<double>(pt.x()), unscale<double>(pt.y())); }
|
||||||
|
Loading…
Reference in New Issue
Block a user