57 template <
typename BV1, 
typename BV2>
 
   59   static void convert(
const BV1& bv1, 
const Transform3s& 
tf1, BV2& bv2);
 
   60   static void convert(
const BV1& bv1, BV2& bv2);
 
   65 struct Converter<AABB, AABB> {
 
   66   static void convert(
const AABB& bv1, 
const Transform3s& 
tf1, AABB& bv2) {
 
   67     const Vec3s& center = bv1.center();
 
   69     const Vec3s center2 = 
tf1.transform(center);
 
   70     bv2.min_ = center2 - Vec3s::Constant(
r);
 
   71     bv2.max_ = center2 + Vec3s::Constant(
r);
 
   74   static void convert(
const AABB& bv1, AABB& bv2) { bv2 = bv1; }
 
   78 struct Converter<AABB, OBB> {
 
   79   static void convert(
const AABB& bv1, 
const Transform3s& 
tf1, OBB& bv2) {
 
   80     bv2.To = 
tf1.transform(bv1.center());
 
   81     bv2.extent.noalias() = (bv1.max_ - bv1.min_) * 0.5;
 
   82     bv2.axes = 
tf1.getRotation();
 
   85   static void convert(
const AABB& bv1, OBB& bv2) {
 
   86     bv2.To = bv1.center();
 
   87     bv2.extent.noalias() = (bv1.max_ - bv1.min_) * 0.5;
 
   88     bv2.axes.setIdentity();
 
   93 struct Converter<OBB, OBB> {
 
   94   static void convert(
const OBB& bv1, 
const Transform3s& 
tf1, OBB& bv2) {
 
   95     bv2.extent = bv1.extent;
 
   96     bv2.To = 
tf1.transform(bv1.To);
 
   97     bv2.axes.noalias() = 
tf1.getRotation() * bv1.axes;
 
  100   static void convert(
const OBB& bv1, OBB& bv2) { bv2 = bv1; }
 
  104 struct Converter<OBBRSS, OBB> {
 
  105   static void convert(
const OBBRSS& bv1, 
const Transform3s& 
tf1, OBB& bv2) {
 
  106     Converter<OBB, OBB>::convert(bv1.obb, 
tf1, bv2);
 
  109   static void convert(
const OBBRSS& bv1, OBB& bv2) {
 
  110     Converter<OBB, OBB>::convert(bv1.obb, bv2);
 
  115 struct Converter<RSS, OBB> {
 
  116   static void convert(
const RSS& bv1, 
const Transform3s& 
tf1, OBB& bv2) {
 
  117     bv2.extent = 
Vec3s(bv1.length[0] * 0.5 + bv1.radius,
 
  118                        bv1.length[1] * 0.5 + bv1.radius, bv1.radius);
 
  119     bv2.To = 
tf1.transform(bv1.Tr);
 
  120     bv2.axes.noalias() = 
tf1.getRotation() * bv1.axes;
 
  123   static void convert(
const RSS& bv1, OBB& bv2) {
 
  124     bv2.extent = 
Vec3s(bv1.length[0] * 0.5 + bv1.radius,
 
  125                        bv1.length[1] * 0.5 + bv1.radius, bv1.radius);
 
  131 template <
typename BV1>
 
  132 struct Converter<BV1, AABB> {
 
  133   static void convert(
const BV1& bv1, 
const Transform3s& 
tf1, AABB& bv2) {
 
  134     const Vec3s& center = bv1.center();
 
  136     const Vec3s center2 = 
tf1.transform(center);
 
  137     bv2.min_ = center2 - Vec3s::Constant(
r);
 
  138     bv2.max_ = center2 + Vec3s::Constant(
r);
 
  141   static void convert(
const BV1& bv1, AABB& bv2) {
 
  142     const Vec3s& center = bv1.center();
 
  144     bv2.min_ = center - Vec3s::Constant(
r);
 
  145     bv2.max_ = center + Vec3s::Constant(
r);
 
  149 template <
typename BV1>
 
  150 struct Converter<BV1, OBB> {
 
  151   static void convert(
const BV1& bv1, 
const Transform3s& 
tf1, OBB& bv2) {
 
  153     Converter<BV1, AABB>::convert(bv1, bv);
 
  154     Converter<AABB, OBB>::convert(bv, 
tf1, bv2);
 
  157   static void convert(
const BV1& bv1, OBB& bv2) {
 
  159     Converter<BV1, AABB>::convert(bv1, bv);
 
  160     Converter<AABB, OBB>::convert(bv, bv2);
 
  165 struct Converter<OBB, RSS> {
 
  166   static void convert(
const OBB& bv1, 
const Transform3s& 
tf1, RSS& bv2) {
 
  167     bv2.Tr = 
tf1.transform(bv1.To);
 
  168     bv2.axes.noalias() = 
tf1.getRotation() * bv1.axes;
 
  170     bv2.radius = bv1.extent[2];
 
  171     bv2.length[0] = 2 * (bv1.extent[0] - bv2.radius);
 
  172     bv2.length[1] = 2 * (bv1.extent[1] - bv2.radius);
 
  175   static void convert(
const OBB& bv1, RSS& bv2) {
 
  179     bv2.radius = bv1.extent[2];
 
  180     bv2.length[0] = 2 * (bv1.extent[0] - bv2.radius);
 
  181     bv2.length[1] = 2 * (bv1.extent[1] - bv2.radius);
 
  186 struct Converter<RSS, RSS> {
 
  187   static void convert(
const RSS& bv1, 
const Transform3s& 
tf1, RSS& bv2) {
 
  188     bv2.Tr = 
tf1.transform(bv1.Tr);
 
  189     bv2.axes.noalias() = 
tf1.getRotation() * bv1.axes;
 
  191     bv2.radius = bv1.radius;
 
  192     bv2.length[0] = bv1.length[0];
 
  193     bv2.length[1] = bv1.length[1];
 
  196   static void convert(
const RSS& bv1, RSS& bv2) { bv2 = bv1; }
 
  200 struct Converter<OBBRSS, RSS> {
 
  201   static void convert(
const OBBRSS& bv1, 
const Transform3s& 
tf1, RSS& bv2) {
 
  202     Converter<RSS, RSS>::convert(bv1.rss, 
tf1, bv2);
 
  205   static void convert(
const OBBRSS& bv1, RSS& bv2) {
 
  206     Converter<RSS, RSS>::convert(bv1.rss, bv2);
 
  211 struct Converter<AABB, RSS> {
 
  212   static void convert(
const AABB& bv1, 
const Transform3s& 
tf1, RSS& bv2) {
 
  213     bv2.Tr = 
tf1.transform(bv1.center());
 
  216     CoalScalar d[3] = {bv1.width(), bv1.height(), bv1.depth()};
 
  217     Eigen::DenseIndex 
id[3] = {0, 1, 2};
 
  219     for (Eigen::DenseIndex i = 1; i < 3; ++i) {
 
  220       for (Eigen::DenseIndex j = i; j > 0; --j) {
 
  221         if (d[j] > d[j - 1]) {
 
  228             Eigen::DenseIndex tmp = 
id[j];
 
  236     const Vec3s extent = (bv1.max_ - bv1.min_) * 0.5;
 
  237     bv2.radius = extent[
id[2]];
 
  238     bv2.length[0] = (extent[
id[0]] - bv2.radius) * 2;
 
  239     bv2.length[1] = (extent[
id[1]] - bv2.radius) * 2;
 
  242     const bool left_hand = (
id[0] == (
id[1] + 1) % 3);
 
  244       bv2.axes.col(0) = -
R.col(
id[0]);
 
  246       bv2.axes.col(0) = 
R.col(
id[0]);
 
  247     bv2.axes.col(1) = 
R.col(
id[1]);
 
  248     bv2.axes.col(2) = 
R.col(
id[2]);
 
  251   static void convert(
const AABB& bv1, RSS& bv2) {
 
  252     convert(bv1, Transform3s(), bv2);
 
  257 struct Converter<AABB, OBBRSS> {
 
  258   static void convert(
const AABB& bv1, 
const Transform3s& 
tf1, OBBRSS& bv2) {
 
  259     Converter<AABB, OBB>::convert(bv1, 
tf1, bv2.obb);
 
  260     Converter<AABB, RSS>::convert(bv1, 
tf1, bv2.rss);
 
  263   static void convert(
const AABB& bv1, OBBRSS& bv2) {
 
  264     Converter<AABB, OBB>::convert(bv1, bv2.obb);
 
  265     Converter<AABB, RSS>::convert(bv1, bv2.rss);
 
  275 template <
typename BV1, 
typename BV2>
 
  277   details::Converter<BV1, BV2>::convert(bv1, 
tf1, bv2);
 
  282 template <
typename BV1, 
typename BV2>
 
  283 static inline void convertBV(
const BV1& bv1, BV2& bv2) {
 
  284   details::Converter<BV1, BV2>::convert(bv1, bv2);