Consistent point in path from convexHull

Hi all,

I generating a PolyLine2f using the convexHull function, with that path I need to find two points in it. Everything is fine when the polyline is static, but if the convex hull points move’s around I get some glitches from the fact it changes the point indexed at 0, making getPosition (float t) const useless…

My initial solution is to make a line crossing the polygon and calculate it’s intersection points with the shape.

so…

  1. Is there an easy way of calculating this intersections with cinder already?
  2. Anyone with a better idea? :stuck_out_tongue:

I made a little video that show’s the getPosition (0.0f) jumping around…
Video

thankss

I am not sure what you mean by “I need to find two points in it”. But the Path2d class has more functionality than the PolyLine class and is more flexible as it allows you to add arcs and curve segments as well. You can call the lineTo() function to initialize it and then use non-const getPoints() or setPoint() to move the points around. The contains() function will tell you if a point is inside the (closed) shape.

I recently made a pull-request that adds distance functions to Path2d, allowing you to calculate the distance of a point and the shape.

-Paul