IMP  2.0.1
The Integrative Modeling Platform
Cone3D.h
Go to the documentation of this file.
1 /**
2  * \file IMP/algebra/Cone3D.h
3  * \brief stores a cone
4  *
5  * Copyright 2007-2013 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 
23 IMPALGEBRA_BEGIN_NAMESPACE
24 /**
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 {
33  public:
34  Cone3D(){}
35  // A cone with a top at s.get_point(0) and the given base radius
36  Cone3D(const Segment3D &s,double radius);
37  //!Get the vertex of the cone
38  Vector3D get_tip() const {return seg_.get_point(0);}
39  //!Get the direction of the axis of the cone
40  /** This vector points from the tip into the occupied volume.
41  */
42  Vector3D get_direction() const {return seg_.get_direction();}
43  double get_height() const {return seg_.get_length();}
44  /** The opening angle of a cone is the vertex angle made by a cross section
45  through the apex and center of the base.*/
46  double get_angle() const {
47  return 2.*std::atan(radius_ / get_height());
48  }
49  //! get the radius of the base circle
50  double get_radius() const {return radius_;}
51  bool get_contains(const Vector3D &v) const;
52  //! Get the plane supporting the base of the cone
53  /** The cone is on the positive side of the plane.
54  */
55  Plane3D get_base_plane() const;
56  IMP_SHOWABLE_INLINE(Cone3D, out << seg_ << ": " << radius_;);
57  private:
58  Segment3D seg_;
59  double radius_;
60 };
61 
62 IMP_VOLUME_GEOMETRY_METHODS(Cone3D, cone_3d,
66 IMPALGEBRA_END_NAMESPACE
67 
68 #endif /* IMPALGEBRA_CONE_3D_H */