Example #1
0
/**
 * {@inheritDoc}
 */
list<Polar> APF::findLocalMinima(list<Polar> points) {
    // List of local minima that have been found.
    list<Polar> localMinima;
    // Whether the last angle's distance was smaller than the current one.
    bool lastWasCloser = false;
    // The previous point; init to an invalid point.
    Polar prev = {-1.0, 0.0};
    for (list<Polar>::iterator i = points.begin(); i != points.end(); i++) {
        Polar p = *i;
        // If p is a valid point and closer than the previous one.
        if (p.isValid() && (!prev.isValid() || p.d < prev.d)) {
            // We mark it as a potential candidate for being a local minima.
            lastWasCloser = true;
        } else {
            // Otherwise if i-1 was closer than i-2, i-1 is a local minima.
            if (lastWasCloser) {
                localMinima.push_back(prev);
            }
            lastWasCloser = false;;
        }
        prev = p;
    }
    // Check in case the last point was a minima.
    if (lastWasCloser) {
        localMinima.push_back(prev);
    }
    return localMinima;
}
Example #2
0
void
Vector2::set( const Polar& p ) {
  __X = p.radius * cos(p.theta);
  __Y = p.radius * sin(p.theta)
  GEOM_ASSERT(p.isValid());
  GEOM_ASSERT(isValid());
}
Example #3
0
Vector2::Vector2( const Polar& p ) :
  Tuple2<real_t>(p.radius * cos(p.theta), p.radius * sin(p.theta)) {
  GEOM_ASSERT(p.isValid());
  GEOM_ASSERT(isValid());
}