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.

Public Functions

HalfSpaceSine(std::shared_ptr<FormulaSineWave> sine_wave, argtype args = argtype())

args:

  • wave_dimension : the wave travels along this dimension.

const FormulaSineWave &sine_wave() const

Return the sine wave formula.

int wave_dimension() const

Return the dimension along which the wave travels.

bool is_inside(const Position &point) const

Return true if the point is inside of the shape.

bool is_inside(const Position &point, const double diameter) const

Return true if the sphere of given center point and diameter is entirely inside of the shape.

double nearest_distance(const Position &point) const

Return the distance from the point to the nearest point on the surface. The distance is negative if the point is inside of the shape and positive if it is outside.