HalfSpaceSine

class HalfSpaceSine : public feasst::HalfSpace

Similar to HalfSpace, which divides space by a plane (or line in 2D), except that space is divided by a sine wave instead. FormulaSineWave describes the surface. Note that the “y” coordinate refers to the one specified in the “dimension” input argument. Thus, the “intersect” argument in HalfSpace overrides the “shift” argument in FormulaSineWave. The “x” coordinate is given by wave_dimension.

To find the nearest distance of the sine wall from the point, the squared distance, \(D^2\) of the point (e,f) to the sine wave,

\(D^2 = (x-e)^2 + (y-f)^2\)

should be a minimum. Thus, the derivative should be zero.

\(\frac{d D^2}{2dx} = 0 = x-e+(y-f) \frac{dy}{dx}\)

For this implementation, we begin by finding the limits of the nearest half-wave of interest, in order to bracket the possible solutions to this non-linear equation. When f > y(e), the “x”-values of the half-wave of interest is given by the nearest minimum to e, and then the nearest maximum on the other side of e. Otherwise, when f < y(e), switch the minimum and maximum in above. When f = y(e), (e,f) is on the curve and your nearest distance is 0.