Collision Checker
sphere.h
Go to the documentation of this file.
1 #ifndef SPHERE_H_
2 #define SPHERE_H_
3 
4 #include <Eigen/Dense>
5 #include <iostream>
6 
8 
9 namespace collision {
14 class Sphere : public Shape {
15  public:
16  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
17 
18  Sphere(double radius, const Eigen::Vector2d &_center = Eigen::Vector2d(0, 0))
19  : Shape(_center) {
20  radius_ = radius;
21  }
22 
23  Sphere(double radius, double x, double y) : Shape(Eigen::Vector2d(x, y)) {
24  radius_ = radius;
25  }
26 
27  bool rayTrace(const Eigen::Vector2d &point1, const Eigen::Vector2d &point2,
28  std::vector<LineSegment> &intersect) const override;
29 
31  void) const override;
33  const std::shared_ptr<fcl::CollisionGeometry<FCL_PRECISION>> &)
34  const override;
35 
36  ~Sphere() {}
37 
38  virtual CollisionObjectType getCollisionObjectType() const override {
40  };
41 
42  Sphere(const Sphere &copy);
43  Sphere *clone() const;
44 
45  void print(std::ostringstream &stream) const;
46 
47  void set_radius(double _radius);
48  double radius() const { return radius_; };
49  double get_x() const { return center_(0); };
50  double get_y() const { return center_(1); };
51 
52  ShapeType type() const;
53 
54 #if ENABLE_SERIALIZER
55  serialize::ICollisionObjectExport *exportThis(void) const override;
56 #endif
57 
58  private:
59  using Shape::center_;
60  using Shape::radius_;
61 
62  static constexpr ShapeType type_ = TYPE_SPHERE;
63 };
64 
65 } // namespace collision
66 
67 #endif
double radius_
Definition: shape.h:73
ShapeType type() const
Get shape type.
Definition: sphere.cc:107
double get_x() const
Definition: sphere.h:49
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Sphere(double radius, const Eigen::Vector2d &_center=Eigen::Vector2d(0, 0))
Definition: sphere.h:18
fcl::CollisionGeometry< FCL_PRECISION > * createFCLCollisionGeometry(void) const override
Definition: sphere.cc:17
bool rayTrace(const Eigen::Vector2d &point1, const Eigen::Vector2d &point2, std::vector< LineSegment > &intersect) const override
Definition: sphere.cc:30
Circle.
Definition: sphere.h:14
Sphere(double radius, double x, double y)
Definition: sphere.h:23
ShapeType
Definition: shape.h:13
void print(std::ostringstream &stream) const
Print all parameters of the shape.
Definition: sphere.cc:96
void set_radius(double _radius)
Definition: sphere.cc:102
Base prototype for the shape of an obstacle.
Definition: shape.h:25
double get_y() const
Definition: sphere.h:50
Sphere * clone() const
Definition: sphere.cc:89
virtual CollisionObjectType getCollisionObjectType() const override
Definition: sphere.h:38
double radius() const
Definition: sphere.h:48
Eigen::Vector2d center_
Definition: shape.h:72
fcl::CollisionObject< FCL_PRECISION > * createFCLCollisionObject(const std::shared_ptr< fcl::CollisionGeometry< FCL_PRECISION >> &) const override
Definition: sphere.cc:22