Signed distance field for a helical tube: a spring, a coil or a thread, with rounded ends.
More...
|
|
| HelixSDF ()=default |
| | Default constructor. Constructs a helix from (0,-1,0) to (0,1,0) in 4 turns of radius 0.5, starting along x, with a tube radius of 0.1.
|
| |
| | HelixSDF (const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T a_helixRadius, const T a_turns, const T a_tubeRadius, const Vec3T< T > &a_startDirection) |
| | Full constructor.
|
| |
|
| HelixSDF (const HelixSDF &)=default |
| | Copy constructor.
|
| |
|
| HelixSDF (HelixSDF &&)=default |
| | Move constructor.
|
| |
| HelixSDF & | operator= (const HelixSDF &)=default |
| | Copy assignment.
|
| |
| HelixSDF & | operator= (HelixSDF &&)=default |
| | Move assignment.
|
| |
| const Vec3T< T > & | getCenter1 () const noexcept |
| | Get the axis point at the first end.
|
| |
| const Vec3T< T > & | getCenter2 () const noexcept |
| | Get the axis point at the second end.
|
| |
| const T & | getHelixRadius () const noexcept |
| | Get the helix radius.
|
| |
| const T & | getTurns () const noexcept |
| | Get the number of turns.
|
| |
| const T & | getTubeRadius () const noexcept |
| | Get the tube radius.
|
| |
| const Vec3T< T > & | getStartDirection () const noexcept |
| | Get the unit direction from the axis to the center line at the first end.
|
| |
| Vec3T< T > | centerLine (const T a_angle) const noexcept |
| | Get the point on the center line at a helix angle.
|
| |
| T | signedDistance (const Vec3T< T > &a_point) const noexcept |
| | Signed distance function for the helix.
|
| |
| BoundingVolumes::AABBT< T > | computeBoundingVolume () const noexcept |
| | The shape's axis-aligned bounding box: that of the cylinder the tube fits in.
|
| |
|
|
Vec3T< T > | m_center1 = Vec3T<T>(T(0), T(-1), T(0)) |
| | The axis point at the first end.
|
| |
|
Vec3T< T > | m_center2 = Vec3T<T>(T(0), T(1), T(0)) |
| | The axis point at the second end.
|
| |
|
Vec3T< T > | m_axis = Vec3T<T>(T(0), T(1), T(0)) |
| | Unit axis from m_center1 to m_center2.
|
| |
|
Vec3T< T > | m_start = Vec3T<T>(T(1), T(0), T(0)) |
| | Unit direction to the center line at the first end.
|
| |
|
T | m_helixRadius = T(0.5) |
| | The helix radius.
|
| |
|
T | m_turns = T(4) |
| | The number of turns.
|
| |
|
T | m_tubeRadius = T(0.1) |
| | The tube's radius.
|
| |
template<class T>
class EBGeometry::HelixSDF< T >
Signed distance field for a helical tube: a spring, a coil or a thread, with rounded ends.
The tube's center line is a right-handed helix around the axis from the first end center to the second, starting from the first in the given direction across the axis; Reflect makes a left-handed one. The value is the distance to the center line less the tube's radius, exact. The squared distance to the line, as a function of the helix angle, is searched turn by turn, in windows of one turn centered on the point's own angle: in each, it has at most one minimum inside, where its derivative increases, which Newton steps kept in a bracket find; the window's ends and the helix' ends are the other candidates. The search starts at the turn nearest the point's height and goes outward while a lower bound on a window's distance (its height difference alone) can still beat the best, which is one to three windows for most points. The tube must not touch itself: its radius is less than the helix radius, and less than half the closest distance between the center line's neighboring turns, which is a little less than the pitch. By default the helix runs from (0,-1,0) to (0,1,0) in 4 turns of radius 0.5 starting along x, with a tube radius of 0.1.
- Template Parameters
-
| T | Floating-point precision. |
template<class T >
| T EBGeometry::HelixSDF< T >::windowMinimum |
( |
const T |
a_k, |
|
|
const T |
a_rho, |
|
|
const T |
a_phi, |
|
|
const T |
a_y, |
|
|
const T |
a_rate, |
|
|
const T |
a_last |
|
) |
| const |
|
inlineprotectednoexcept |
The smallest squared distance from a point to the center line over one window of helix angles, phi + 2 pi k + s with |s| <= pi, cut to the helix' angles.
f(s) = rho^2 + R^2 - 2 rho R cos(s) + (Y - rate s)^2, with Y the point's height over the line at s = 0. Its derivative is 2 g(s), g(s) = rho R sin(s) + rate^2 s - rate Y, which increases where rho R cos(s) + rate^2 > 0, on (-s_c, s_c), and decreases outside it. A minimum inside the window is therefore where g crosses zero in (-s_c, s_c), at most once; otherwise f is least at an end. Out of line on a device (the helix' solver): inlined, it would be copied into every level of every tape kernel, whatever shapes the tape holds, which makes the device compile of every tape kernel much slower. A call costs little beside the search.
- Parameters
-
| [in] | a_k | The window, as a whole number. |
| [in] | a_rho | The point's distance from the axis. |
| [in] | a_phi | The point's angle around the axis, from the start direction. |
| [in] | a_y | The point's height along the axis, from the first end. |
| [in] | a_rate | The rise per radian. |
| [in] | a_last | The last angle, 2 pi times the turns. |
- Returns
- The squared distance.