3 #include <fcl/narrowphase/collision.h> 4 #include <fcl/narrowphase/collision_object.h> 25 const Eigen::Vector2d &point2,
26 std::vector<LineSegment> &intersect)
const {
29 std::vector<Eigen::Vector2d> inters1;
31 for (
auto &segm : segments_) {
32 res = segm.intersect(ray_segment, inters1) || res;
46 <<
"), r: (" << r_(0) <<
"|" << r_(1) <<
") " 47 <<
"Local coordinate axes: (" << local_axes_(0, 0) <<
"," 48 << local_axes_(1, 0) <<
"), (" << local_axes_(0, 1) <<
"," 49 << local_axes_(1, 1) <<
")" << std::endl;
55 return local_axes_.col(0);
59 return local_axes_.col(1);
71 throw "Rectangle_OBB: Not a valid index for r";
80 local_axes_.col(0) = x_axis;
82 is_fastAABB_cached_ =
false;
83 is_orientation_cached_ =
false;
87 local_axes_.col(1) = y_axis;
89 is_fastAABB_cached_ =
false;
90 is_orientation_cached_ =
false;
96 is_fastAABB_cached_ =
false;
102 is_fastAABB_cached_ =
false;
106 if (is_orientation_cached_)
107 return cached_orientation_;
109 compute_orientation();
110 return cached_orientation_;
113 void RectangleOBB::compute_orientation()
const {
114 Eigen::Matrix2d temp_matrix;
116 temp_matrix.col(1) = Eigen::Vector2d(1, 0);
117 double dot = temp_matrix.col(0).dot(temp_matrix.col(1));
118 double det = temp_matrix.determinant();
119 cached_orientation_ =
120 -1 * std::atan2(det, dot);
121 is_orientation_cached_ =
true;
127 Eigen::Vector2d t = local_axes_.transpose() * (p -
center_);
129 for (
int i = 0; i < 2; i++) {
131 sq_dis += pow(t(i) + r_(i), 2);
132 }
else if (t(i) > r_(i)) {
133 sq_dis += pow(t(i) - r_(i), 2);
139 #if ENABLE_SERIALIZER 146 return serialize::exportObject(*
this);
Eigen::Vector2d local_y_axis() const
void set_local_x_axis(const Eigen::Vector2d &x_axis)
ShapeType type() const
Get shape type.
double orientation() const
fcl::CollisionObject< FCL_PRECISION > * createFCLCollisionObject(const std::shared_ptr< fcl::CollisionGeometry< FCL_PRECISION >> &) const override
double squareDisToPoint(const Eigen::Vector2d &p) const
double det(double a, double b, double c, double d)
bool rayTracePostprocess(const Eigen::Vector2d &point1, const Eigen::Vector2d &point2, std::vector< Eigen::Vector2d > inters1, std::vector< LineSegment > &intersect, const collision::CollisionObject *obj)
void invalidateCollisionEntityCache(void)
fcl::CollisionGeometry< FCL_PRECISION > * createFCLCollisionGeometry(void) const override
void set_r_y(double _r_y)
RectangleOBB(const detail::OBB &obb)
Eigen::Vector2d r() const
void set_local_y_axis(const Eigen::Vector2d &y_axis)
void set_r_x(double _r_x)
virtual RectangleOBB * clone() const
void print(std::ostringstream &stream) const
Print all parameters of the shape.
int serialize(const test::BroadphaseFailureCCObj &bf_object, std::ostream &output_stream, const char *format=SERIALIZER_DEFAULT_FORMAT)
Eigen::Vector2d local_x_axis() const
Eigen::Matrix2d local_axes() const
Eigen::Vector2d center() const
Get geometric center of shape.
bool rayTrace(const Eigen::Vector2d &point1, const Eigen::Vector2d &point2, std::vector< LineSegment > &intersect) const override