26 #ifdef BOOST_NO_STDC_NAMESPACE 44 template <
class coordT>
78 const coordT eps = d0d0 * 10E-5;
80 const coordT denom =
square(d0d1) - d0d0 * d1d1;
81 coordT distance_squared;
82 if (std::fabs(denom) <= eps)
85 const coordT a0 = r10d0 / d0d0;
86 result = r0 + d0 * a0;
87 distance_squared = r10r10 -
square(r10d0) / d0d0;
92 const coordT a0 = (-d1d1 * r10d0 + d0d1 * r10d1) / denom;
93 const coordT a1 = (-d0d1 * r10d0 + d0d0 * r10d1) / denom;
95 result = ((r0 + d0 * a0) + (r1 + d1 * a1)) / 2;
96 distance_squared = (d1d1 *
square(r10d0) - 2 * d0d1 * r10d0 * r10d1 + d0d0 *
square(r10d1)) / denom + r10r10;
98 if (distance_squared >= 0)
99 return std::sqrt(distance_squared);
102 if (-distance_squared < eps)
107 return std::sqrt(distance_squared);
116 template <
class coordT>
141 const coordT distance_squared = r10r10 -
square(r10d0) / d0d0;
142 if (distance_squared >= 0)
143 return std::sqrt(distance_squared);
146 if (-distance_squared < d0d0 * 10E-5)
151 return std::sqrt(distance_squared);
161 template <
class coordT>
176 r1.x() = p1.x() + u * difference.x();
177 r1.y() = p1.y() + u * difference.y();
178 r1.z() = p1.z() + u * difference.z();
a templated class for 3-dimensional coordinates.
Definition: CartesianCoordinate3D.h:52
defines various classes for specifying a line in 3 dimensions
void project_point_on_a_line(const CartesianCoordinate3D< coordT > &p1, const CartesianCoordinate3D< coordT > &p2, CartesianCoordinate3D< coordT > &r1)
Project a point on a line.
Definition: line_distances.h:163
A class for LORs.
Definition: CListRecord.h:39
coordT inner_product(const BasicCoordinate< num_dimensions, coordT > &p1, const BasicCoordinate< num_dimensions, coordT > &p2)
compute sum_i p1[i] * p2[i]
Definition: BasicCoordinate.inl:408
NUMBER square(const NUMBER &x)
returns the square of a number, templated.
Definition: common.h:146
coordT distance_between_line_and_point(const LORAs2Points< coordT > &line, const CartesianCoordinate3D< coordT > &r1)
find the distance between a point and a line
Definition: line_distances.h:118
defines the stir::CartesianCoordinate3D<coordT> class
coordT coordinate_between_2_lines(CartesianCoordinate3D< coordT > &result, const LORAs2Points< coordT > &line0, const LORAs2Points< coordT > &line1)
find a point half-way between 2 lines and their distance
Definition: line_distances.h:46