1 #include <fcl/narrowphase/collision.h> 2 #include <fcl/narrowphase/collision_object.h> 6 #include <fcl/geometry/bvh/BVH_model.h> 17 :
Shape(copy), v1_(copy.
v1()), v2_(copy.
v2()), v3_(copy.
v3()) {
24 const Eigen::Vector2d &point2,
25 std::vector<LineSegment> &intersect)
const {
28 std::vector<Eigen::Vector2d> inters1;
30 for (
auto &segm : segments_) {
31 res = segm.intersect(obj_segment, inters1) || res;
42 stream <<
"Triangle: \nVertices:" 43 <<
"(" << v1_(0) <<
"|" << v1_(1) <<
"), " 44 <<
"(" << v2_(0) <<
"|" << v2_(1) <<
"), " 45 <<
"(" << v3_(0) <<
"|" << v3_(1) <<
"), " 52 fcl::BVHModel<fcl::AABB<FCL_PRECISION>> *model =
53 new fcl::BVHModel<fcl::AABB<FCL_PRECISION>>();
54 model->beginModel(1, 3);
56 Eigen::Vector2d v2d =
v1();
57 fcl::Vector3<FCL_PRECISION>
v1(v2d[0], v2d[1], 0);
59 fcl::Vector3<FCL_PRECISION>
v2(v2d[0], v2d[1], 0);
61 fcl::Vector3<FCL_PRECISION>
v3(v2d[0], v2d[1], 0);
63 model->addTriangle(v1, v2, v3);
101 Eigen::Vector2d Triangle::compute_center() {
102 double x = (v1_(0) + v2_(0) + v3_(0)) / 3.0;
103 double y = (v1_(1) + v2_(1) + v3_(1)) / 3.0;
104 return Eigen::Vector2d(x, y);
107 void Triangle::compute_incircle_radius_and_center() {
109 double a = (v2_ - v1_).norm();
110 double b = (v3_ - v2_).norm();
111 double c = (v3_ - v1_).norm();
113 double p = 0.5 * (a + b + c);
115 double area = std::sqrt(p * (p - a) * (p - b) * (p - c));
117 incenter_ = (b * v1_ + c * v2_ + a * v3_) / (2.0 * p);
119 incircle_radius_ = area / p;
122 #if ENABLE_SERIALIZER 129 return serialize::exportObject(*
this);
std::vector< LineSegment > segments(void) const
Eigen::Vector2d v2() const
double incircle_radius() const
bool rayTracePostprocess(const Eigen::Vector2d &point1, const Eigen::Vector2d &point2, std::vector< Eigen::Vector2d > inters1, std::vector< LineSegment > &intersect, const collision::CollisionObject *obj)
Eigen::Vector2d v1() const
Eigen::Vector2d v3() const
void invalidateCollisionEntityCache(void)
void set_v2(const Eigen::Vector2d &_v2)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Triangle(const Eigen::Vector2d &_v1=Eigen::Vector2d(0, 0), const Eigen::Vector2d &_v2=Eigen::Vector2d(0, 0), const Eigen::Vector2d &_v3=Eigen::Vector2d(0, 0))
void print(std::ostringstream &stream) const
Print all parameters of the shape.
void set_v1(const Eigen::Vector2d &_v1)
Eigen::Vector2d center() const
Base prototype for the shape of an obstacle.
void set_v3(const Eigen::Vector2d &_v3)
int serialize(const test::BroadphaseFailureCCObj &bf_object, std::ostream &output_stream, const char *format=SERIALIZER_DEFAULT_FORMAT)
ShapeType type() const
Get shape type.
Eigen::Vector2d incenter() const
bool rayTrace(const Eigen::Vector2d &point1, const Eigen::Vector2d &point2, std::vector< LineSegment > &intersect) const override