IMP  2.4.0
The Integrative Modeling Platform
Cone3D.h
Go to the documentation of this file.
1 /**
2  * \file IMP/algebra/Cone3D.h
3  * \brief Represent a cone in 3D.
4  *
5  * Copyright 2007-2015 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPALGEBRA_CONE_3D_H
9 #define IMPALGEBRA_CONE_3D_H
10 
11 #include "Vector3D.h"
12 #include "Sphere3D.h"
13 #include "SpherePatch3D.h"
14 #include "Plane3D.h"
15 #include "Segment3D.h"
16 #include "GeometricPrimitiveD.h"
19 #include <iostream>
20 #include "constants.h"
21 
22 IMPALGEBRA_BEGIN_NAMESPACE
23 
24 //! Represent a cone in 3D.
25 /** In general, a cone is a pyramid with a circular cross section.
26  A right cone is a cone with its vertex above the center of its base.
27  However, when used without qualification, the term "cone" often means
28  "right cone." We have implemented a "right cone".
29  \geometry
30  */
31 class IMPALGEBRAEXPORT Cone3D : public GeometricPrimitiveD<3> {
32  public:
33  Cone3D() {}
34  //! Make with top at s.get_point(0), base at s.get_point(1) with given radius
35  Cone3D(const Segment3D &s, double radius);
36  //! Get the vertex of the cone
37  Vector3D get_tip() const { return seg_.get_point(0); }
38  //! Get the direction of the axis of the cone
39  /** This vector points from the tip into the occupied volume.
40  */
41  Vector3D get_direction() const { return seg_.get_direction(); }
42  double get_height() const { return seg_.get_length(); }
43  /** The opening angle of a cone is the vertex angle made by a cross section
44  through the apex and center of the base.*/
45  double get_angle() const { return 2. * std::atan(radius_ / get_height()); }
46  //! Get the radius of the base circle
47  double get_radius() const { return radius_; }
48  //! Return True iff the given point is inside the volume.
49  bool get_contains(const Vector3D &v) const;
50  //! Get the plane supporting the base of the cone
51  /** The cone is on the positive side of the plane.
52  */
53  Plane3D get_base_plane() const;
54  IMP_SHOWABLE_INLINE(Cone3D, out << seg_ << ": " << radius_;);
55 
56  private:
57  Segment3D seg_;
58  double radius_;
59 };
60 
61 IMP_VOLUME_GEOMETRY_METHODS(Cone3D, cone_3d, IMP_UNUSED(g);
65 IMPALGEBRA_END_NAMESPACE
66 
67 #endif /* IMPALGEBRA_CONE_3D_H */
Basic types used by IMP.
double get_angle() const
Definition: Cone3D.h:45
Simple 3D sphere patch class.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
Simple implementation of segments in 3D.
Vector3D get_tip() const
Get the vertex of the cone.
Definition: Cone3D.h:37
Base class for geometric types.
Various general useful macros for IMP.
#define IMP_UNUSED(variable)
Vector3D get_direction() const
Get the direction of the axis of the cone.
Definition: Cone3D.h:41
#define IMP_VOLUME_GEOMETRY_METHODS(Name, name, area, volume, bounding_box)
Implement the needed namespace methods for a geometry type.
Represent a cone in 3D.
Definition: Cone3D.h:31
double get_radius() const
Get the radius of the base circle.
Definition: Cone3D.h:47
Various useful constants.
Simple implementation of segments in 3D.
Definition: Segment3D.h:24
Simple 3D plane class.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
Simple 3D vector class.
#define IMP_NOT_IMPLEMENTED
Use this to mark that the method is not implemented yet.
Definition: check_macros.h:83
Represent a plane in 3D.
Definition: Plane3D.h:20
Simple 3D sphere class.
Various general useful macros for IMP.