IMP logo
IMP Reference Guide  develop.1a86c4215a,2024/04/24
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-2022 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"
17 #include <IMP/showable_macros.h>
18 #include <IMP/warning_macros.h>
19 #include <cereal/access.hpp>
20 #include <iostream>
21 #include "constants.h"
22 
23 IMPALGEBRA_BEGIN_NAMESPACE
24 
25 //! Represent a cone in 3D.
26 /** In general, a cone is a pyramid with a circular cross section.
27  A right cone is a cone with its vertex above the center of its base.
28  However, when used without qualification, the term "cone" often means
29  "right cone." We have implemented a "right cone".
30  \geometry
31  */
32 class IMPALGEBRAEXPORT Cone3D : public GeometricPrimitiveD<3> {
33  public:
34  Cone3D() {}
35  //! Make with top at s.get_point(0), base at s.get_point(1) with given 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 { return 2. * std::atan(radius_ / get_height()); }
47  //! Get the radius of the base circle
48  double get_radius() const { return radius_; }
49  //! Return True iff the given point is inside the volume.
50  bool get_contains(const Vector3D &v) const;
51  //! Get the plane supporting the base of the cone
52  /** The cone is on the positive side of the plane.
53  */
54  Plane3D get_base_plane() const;
55  IMP_SHOWABLE_INLINE(Cone3D, out << seg_ << ": " << radius_;);
56 
57  private:
58  Segment3D seg_;
59  double radius_;
60 
61  friend class cereal::access;
62 
63  template<class Archive> void serialize(Archive &ar) {
64  ar(seg_, radius_);
65  }
66 };
67 
68 IMP_VOLUME_GEOMETRY_METHODS(Cone3D, cone_3d, IMP_UNUSED(g);
72 IMPALGEBRA_END_NAMESPACE
73 
74 #endif /* IMPALGEBRA_CONE_3D_H */
Base class for geometric types.
double get_height(const Surface &s, const XYZR &d)
Get height of sphere above surface.
Definition: Surface.h:129
double get_angle() const
Definition: Cone3D.h:46
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:38
Base class for geometric types.
Macros to control compiler warnings.
#define IMP_UNUSED(variable)
Vector3D get_direction() const
Get the direction of the axis of the cone.
Definition: Cone3D.h:42
#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:32
double get_radius() const
Get the radius of the base circle.
Definition: Cone3D.h:48
Various useful constants.
Simple implementation of segments in 3D.
Definition: Segment3D.h:25
Simple 3D plane class.
VectorD< 3 > Vector3D
Definition: VectorD.h:408
Simple 3D vector class.
#define IMP_NOT_IMPLEMENTED
Use this to mark that the method is not implemented yet.
Definition: check_macros.h:81
Represent a plane in 3D.
Definition: Plane3D.h:21
Simple 3D sphere class.
Macros to help with objects that can be printed to a stream.