Skip to content
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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

even1024
Copy link
Collaborator

Generic request

  • PR name follows the pattern #1234 – issue name
  • branch name does not contain '#'
  • base branch (master or release/xx) is correct
  • PR is linked with the issue
  • task status changed to "Code review"
  • code follows product standards
  • regression tests updated

@even1024 even1024 marked this pull request as ready for review January 9, 2025 11:28
@@ -822,5 +824,234 @@ namespace indigo
float _d;
};

inline bool isPointInPolygon(const Vec2f& p, const std::vector<Vec2f>& poly)
Copy link
Collaborator

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)
Copy link
Collaborator

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants