-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#2412 - User can't correctly save (or make a layout) to RDF/RXN reaction several products or with separate positioned molecules #2717
base: master
Are you sure you want to change the base?
Conversation
@@ -822,5 +824,234 @@ namespace indigo | |||
float _d; | |||
}; | |||
|
|||
inline bool isPointInPolygon(const Vec2f& p, const std::vector<Vec2f>& poly) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need more comments.
Also no need to calculate x if both vertices has x > px
So I suggest something like
inline bool isPointInPolygon(const Vec2f& p, const std::vector<Vec2f>& poly)
{
// Ray casting algorithm
bool in = false;
for (size_t i = 0, n = poly.size(); i < n; ++i)
{
size_t j = (i + 1) % n;
if (((poly[i].y > p.y) != (poly[j].y > p.y)) && // point y between vertices and
(((p.x > poly[i].x) && (p.x < poly[j].x)) || // both vertices are at right of point or edge is at right of point
(p.x < (poly[i].x + (p.y - poly[i].y) * (poly[j].x - poly[i].x) / (poly[j].y - poly[i].y))))) // py < (py-y0)*dx/dy
in = !in;
}
return in;
}
return result; | ||
} | ||
|
||
inline float convexPolygonArea(const std::vector<Vec2f>& poly) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add comment that this is "Shoelace formula - triangle form"
Generic request
#1234 – issue name