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_; }
43 inline std::pair<double, algebra::Vector3D>
55 return 4.0 * get_squared(
PI)
56 * g.get_major_radius() * g.get_minor_radius(),
57 return 2.0 * get_squared(
PI)
58 * g.get_major_radius()
59 * get_squared(g.get_minor_radius()),
65 std::pair<double, algebra::Vector3D>
66 Torus3D::get_torus_distance
69 double const x=sphere[0];
70 double const y=sphere[1];
71 double const z=sphere[2];
72 const double eps = 1e-9;
73 double d_xy2 = x*x + y*y;
74 double d_xy = std::sqrt(d_xy2);
99 double denom = std::sqrt(z*z + d_tx*d_tx + d_ty*d_ty);
100 double idenom = 1.0/denom;
104 der[0] = d_tx*idenom;
105 der[1] = d_ty*idenom;
114 return std::make_pair(denom - r_ - sphere.get_radius(), der);
118 double dz = z > 0 ? z - r_ - sphere.get_radius(): z + r_ + sphere.get_radius();
119 double denom = std::sqrt(dz*dz + d_tx*d_tx + d_ty*d_ty);
123 der[0] = -d_tx/denom;
124 der[1] = -d_ty/denom;
133 return std::make_pair(-denom - r_ - sphere.get_radius(), der);
139 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.
Various general useful macros for IMP.