IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2026 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"
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
23IMPALGEBRA_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 */
32class 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 */
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
68IMP_VOLUME_GEOMETRY_METHODS(Cone3D, cone_3d, IMP_UNUSED(g);
72IMPALGEBRA_END_NAMESPACE
73
74#endif /* IMPALGEBRA_CONE_3D_H */
Base class for geometric types.
Simple 3D plane class.
Simple implementation of segments in 3D.
Simple 3D sphere class.
Simple 3D sphere patch class.
Simple 3D vector class.
Various useful constants.
#define IMP_NOT_IMPLEMENTED
Use this to mark that the method is not implemented yet.
Vector3D get_direction() const
Get the direction of the axis of the cone.
Definition Cone3D.h:42
Cone3D(const Segment3D &s, double radius)
Make with top at s.get_point(0), base at s.get_point(1) with given radius.
Plane3D get_base_plane() const
Get the plane supporting the base of the cone.
double get_angle() const
Definition Cone3D.h:46
Vector3D get_tip() const
Get the vertex of the cone.
Definition Cone3D.h:38
bool get_contains(const Vector3D &v) const
Return True iff the given point is inside the volume.
double get_radius() const
Get the radius of the base circle.
Definition Cone3D.h:48
Represent a plane in 3D.
Definition Plane3D.h:21
Simple implementation of segments in 3D.
Definition Segment3D.h:24
#define IMP_VOLUME_GEOMETRY_METHODS(Name, name, area, volume, bounding_box)
Implement the needed namespace methods for a geometry type.
VectorD< 3 > Vector3D
Definition VectorD.h:407
Macros to help with objects that can be printed to a stream.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
Macros to control compiler warnings.
#define IMP_UNUSED(variable)