8 #ifndef IMPALGEBRA_TORUS_3D_H
9 #define IMPALGEBRA_TORUS_3D_H
20 IMPALGEBRA_BEGIN_NAMESPACE
29 Torus3D (
double major_radius,
double minor_radius);
30 double get_major_radius()
const {
return R_; }
31 double get_minor_radius()
const {
return r_; }
44 inline std::pair<double, algebra::Vector3D>
56 return 4.0 * get_squared(
PI)
57 * g.get_major_radius() * g.get_minor_radius(),
58 return 2.0 * get_squared(
PI)
59 * g.get_major_radius()
60 * get_squared(g.get_minor_radius()),
66 std::pair<double, algebra::Vector3D>
67 Torus3D::get_torus_distance
70 double const x=sphere[0];
71 double const y=sphere[1];
72 double const z=sphere[2];
73 const double eps = 1e-9;
74 double d_xy2 = x*x + y*y;
75 double d_xy = std::sqrt(d_xy2);
100 double denom = std::sqrt(z*z + d_tx*d_tx + d_ty*d_ty);
101 double idenom = 1.0/denom;
105 der[0] = d_tx*idenom;
106 der[1] = d_ty*idenom;
115 return std::make_pair(denom - r_ - sphere.get_radius(), der);
119 double dz = z > 0 ? z - r_ - sphere.get_radius(): z + r_ + sphere.get_radius();
120 double denom = std::sqrt(dz*dz + d_tx*d_tx + d_ty*d_ty);
124 der[0] = -d_tx/denom;
125 der[1] = -d_ty/denom;
134 return std::make_pair(-denom - r_ - sphere.get_radius(), der);
140 IMPALGEBRA_END_NAMESPACE
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
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.
#define IMP_NOT_IMPLEMENTED
Use this to mark that the method is not implemented yet.
Macros to help with objects that can be printed to a stream.