Rectangle.inside does not work with non-ordered vertices

Issue #83 open
Chaffra Affouda created an issue
r = Rectangle(Point(0,0),Point(-1,-1))
r.inside(Point(-0.5,-0.5))

This returns False but should be True. Here's a fix,

bool Rectangle::inside(dolfin::Point p) const
{
  double ba_x = b.x() - a.x();
  double ba_y = b.y() - a.y();

  double pa_x = (p.x() - a.x())*ba_x/std::abs(ba_x);
  double pa_y = (p.y() - a.y())*ba_y/std::abs(ba_y);

  return pa_x >= 0.0 && pa_x <= 1.0 && pa_y >= 0.0 and pa_y <= 1.0;
}

Comments (8)

  1. Log in to comment