7 #ifndef _CYLINDER_PRIMITIVE_H
8 #define _CYLINDER_PRIMITIVE_H
10 #include <Moby/Primitive.h>
15 class SpherePrimitive;
23 CylinderPrimitive(
double radius,
double height,
unsigned n,
unsigned nrings,
const Ravelin::Pose3d& T);
30 virtual void set_pose(
const Ravelin::Pose3d& T);
31 virtual void load_from_xml(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
32 virtual void save_to_xml(
XMLTreePtr node, std::list<boost::shared_ptr<const Base> >& shared_objects)
const;
34 virtual void get_vertices(boost::shared_ptr<const Ravelin::Pose3d> P, std::vector<Point3d>& vertices)
const;
37 virtual boost::shared_ptr<const IndexedTriArray>
get_mesh(boost::shared_ptr<const Ravelin::Pose3d> P);
41 virtual double get_bounding_radius()
const {
return std::max(_radius, _height); }
53 bool intersect_seg(
const LineSeg3& seg,
double& t,
Point3d& isect, Ravelin::Vector3d& normal)
const;
54 bool point_inside(
const Point3d& p, Ravelin::Vector3d& normal)
const;
56 double calc_penetration_depth(
const Point3d& p)
const;
57 unsigned intersect_line(
const Point3d& origin,
const Ravelin::Vector3d& dir,
double& t0,
double& t1)
const;
58 virtual void calc_mass_properties();
73 std::map<CollisionGeometryPtr, OBBPtr> _obbs;
virtual bool is_convex() const
Determines whether this primitive is convex.
Definition: CylinderPrimitive.h:25
virtual osg::Node * create_visualization()
Creates the visualization for this primitive.
Definition: CylinderPrimitive.cpp:436
boost::shared_ptr< BV > BVPtr
Bounding volume (BV) smart pointer.
Definition: Types.h:92
unsigned get_circle_points() const
Gets the number of points in a circle on the cylinder.
Definition: CylinderPrimitive.h:50
virtual double calc_dist_and_normal(const Point3d &point, std::vector< Ravelin::Vector3d > &normals) const
Computes the signed distance between the cylinder and a point.
Definition: CylinderPrimitive.cpp:148
void set_num_circle_points(unsigned n)
Sets the number of points in the circles of the cylinder.
Definition: CylinderPrimitive.cpp:387
double get_height() const
Gets the height of this cylinder.
Definition: CylinderPrimitive.h:47
CylinderPrimitive()
Constructs a cylinder centered at the origin, with the longitudinal axis aligned with the y-axis...
Definition: CylinderPrimitive.cpp:37
Defines a triangle-mesh-based primitive type used for inertial property calculation and geometry prov...
Definition: Primitive.h:41
virtual void save_to_xml(XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
Implements Base::save_to_xml() for serialization.
Definition: CylinderPrimitive.cpp:486
boost::shared_ptr< CollisionGeometry > CollisionGeometryPtr
Collision geometry smart pointer.
Definition: Types.h:77
virtual boost::shared_ptr< const IndexedTriArray > get_mesh(boost::shared_ptr< const Ravelin::Pose3d > P)
Gets the triangle mesh for the cylinder, computing it if necessary.
Definition: CylinderPrimitive.cpp:403
double get_radius() const
Gets the radius of this cylinder.
Definition: CylinderPrimitive.h:44
boost::shared_ptr< XMLTree > XMLTreePtr
XML tree smart pointer.
Definition: Types.h:104
void set_radius(double radius)
Sets the radius for this cylinder.
Definition: CylinderPrimitive.cpp:339
virtual void get_vertices(boost::shared_ptr< const Ravelin::Pose3d > P, std::vector< Point3d > &vertices) const
Gets vertices from the primitive.
Definition: CylinderPrimitive.cpp:581
virtual Point3d get_supporting_point(const Ravelin::Vector3d &d) const
Gets the supporting point in a particular direction.
Definition: CylinderPrimitive.cpp:126
Ravelin::Vector3d Point3d
Typedef to distinguish between a 3D vector and a point.
Definition: Types.h:47
virtual void set_pose(const Ravelin::Pose3d &T)
Transforms the primitive.
Definition: CylinderPrimitive.cpp:508
Defines a cylinder primitive.
Definition: CylinderPrimitive.h:18
std::pair< Point3d, Point3d > LineSeg3
Typedef to make specifying line segments easier.
Definition: Types.h:50
void set_num_rings(unsigned n)
Sets the number of rings for determining "virtual points" (points on the tube of the cylinder) ...
Definition: CylinderPrimitive.cpp:395
void set_height(double height)
Sets the height for this cylinder.
Definition: CylinderPrimitive.cpp:363
virtual BVPtr get_BVH_root(CollisionGeometryPtr geom)
Gets the OBB.
Definition: CylinderPrimitive.cpp:550
virtual double calc_signed_dist(boost::shared_ptr< const Primitive > p, Point3d &pthis, Point3d &pp) const
Computes the signed distance between this and another primitive.
Represents a sphere primitive for inertia properties, collision detection, and visualization.
Definition: SpherePrimitive.h:18
virtual void load_from_xml(boost::shared_ptr< const XMLTree > node, std::map< std::string, BasePtr > &id_map)
Implements Base::load_from_xml() for serialization.
Definition: CylinderPrimitive.cpp:453