IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
Cylinder3D.h
Go to the documentation of this file.
1 /**
2  * \file IMP/algebra/Cylinder3D.h
3  * \brief Represent a cylinder in 3D.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPALGEBRA_CYLINDER_3D_H
9 #define IMPALGEBRA_CYLINDER_3D_H
10 
11 #include "Vector3D.h"
12 #include "Rotation3D.h"
13 #include "Transformation3D.h"
14 #include "Segment3D.h"
15 #include "GeometricPrimitiveD.h"
16 #include <IMP/showable_macros.h>
17 #include <cereal/access.hpp>
18 #include <iostream>
19 #include "constants.h"
20 
21 IMPALGEBRA_BEGIN_NAMESPACE
22 
23 //! Represent a cylinder in 3D.
24 /**
25  \geometry
26 */
27 class IMPALGEBRAEXPORT Cylinder3D : public GeometricPrimitiveD<3> {
28  public:
29  Cylinder3D() {}
30  Cylinder3D(const Segment3D& s, double radius);
31  double get_radius() const { return radius_; }
32  const Segment3D& get_segment() const { return s_; }
33 
34  /** Returns a point on the surface of the cylinder,
35  specified by its location relative to the cylinder axis
36  and its rotation angle about the axis
37 
38  @param relative_height a number in the range [0..1] that specifies
39  the point location relative to the cylinder axis
40  such that 0 specifies the cylinder bottom and
41  1 specifies its top
42  @param angle angle in radians about the cylinder axis, with 0 set to an
43  arbitrary but consistent direction
44  */
45  const Vector3D get_surface_point_at(double relative_height, double angle);
46 
47  /** Returns a point inside the cylinder,
48  specified by its location relative to the cylinder axis,
49  its relative radius and its rotation angle about the axis
50 
51  @param relative_height a number in the range [0..1] that specifies
52  the point location relative to the cylinder axis
53  such that 0 specifies the cylinder bottom and
54  1 specifies its top
55  @param relative_radius a number in the range [0..1] that specifies
56  the distance of the point from the cylinder axis
57  relative to the cylinder radius, 0 being on the
58  axis itself, and 1 being on the cylinder surface
59  @param angle angle in radians about the cylinder axis, with 0 set to an
60  arbitrary but consistent direction
61  */
62  const Vector3D get_inner_point_at(double relative_height,
63  double relative_radius, double angle) const;
64 
65  IMP_SHOWABLE_INLINE(Cylinder3D, { out << s_ << ": " << radius_; });
66 
67  private:
68  Segment3D s_;
69  double radius_;
70 
71  friend class cereal::access;
72 
73  template<class Archive> void serialize(Archive &ar) {
74  ar(s_, radius_);
75  }
76 };
77 
79  return 2.0 * PI * g.get_radius() *
80  g.get_segment().get_length() +
81  2.0 * PI * get_squared(g.get_radius()),
82  return PI * get_squared(g.get_radius()) *
83  g.get_segment().get_length(),
84  IMP_UNUSED(g);
86 
87 IMPALGEBRA_END_NAMESPACE
88 
89 #endif /* IMPALGEBRA_CYLINDER_3D_H */
Base class for geometric types.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
static const double PI
the constant pi
Represent a cylinder in 3D.
Definition: Cylinder3D.h:27
Simple implementation of segments in 3D.
Base class for geometric types.
#define IMP_UNUSED(variable)
#define IMP_VOLUME_GEOMETRY_METHODS(Name, name, area, volume, bounding_box)
Implement the needed namespace methods for a geometry type.
Various useful constants.
Simple 3D rotation class.
Simple 3D transformation class.
Simple implementation of segments in 3D.
Definition: Segment3D.h:25
VectorD< 3 > Vector3D
Definition: VectorD.h:425
Simple 3D vector class.
#define IMP_NOT_IMPLEMENTED
Use this to mark that the method is not implemented yet.
Definition: check_macros.h:81
DensityMap * get_segment(DensityMap *map_to_segment, int nx_start, int nx_end, int ny_start, int ny_end, int nz_start, int nz_end)
Get a segment of the map according to xyz indexes.
Macros to help with objects that can be printed to a stream.