You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

#pragma once
#include <base/subface.hpp>
namespace internal
{
// local: cylinder face x^2+y^2-1=0
// u: planar angle from x-axis to z-axis
// v: depth/height from xz-plane to y-axis
struct cylinder_face_t final : subface {
};
} // namespace internal
namespace detail
{
template <>
struct hasher<internal::cylinder_face_t> {
// Q' = M^{-T}QM^{-1}
// Q = {
// 1, 0, 0, 0
// 0, 1, 0, 0
// 0, 0, 0, 0
// 0, 0, 0, -1
// }
size_t operator()(const internal::cylinder_face_t& subface) const
{
// build M^{-T}Q directly
Eigen::Matrix4d mat = internal::empty_affine_matrix;
mat.leftCols<2>() = subface.world_to_local.matrix().topRows<2>().transpose();
auto res = mat * subface.world_to_local;
return hash_funcs(res.matrix());
}
// size_t operator()(const internal::cylinder_face_t& subface) const
// {
// auto R = subface.world_to_local.linear().topLeftCorner<2, 3>(); // 2x3
// auto b = subface.local_to_world.translation(); // 3x1
// Eigen::Matrix<double, 3, 4> hash_mat = Eigen::Matrix<double, 3, 4>::Zero();
// hash_mat.topLeftCorner<3, 3>() = R.transpose() * R;
// hash_mat.topRightCorner<2, 1>() = R * b;
// return hash_funcs(hash_mat);
// }
};
} // namespace detail