I’m using Raphaeljs to create a web application for creating diagrams. One of the shapes is a diamond, which is just a rectangle rotated 45 degrees. I need to test whether a circle falls within the rotated image, and I’m not sure how to go about it.
I’m using Raphaeljs to create a web application for creating diagrams. One of the
Share
If you have a diamond:
Then the two corners on the horizontal with have coordinates (nx1, ny) and (nx2, ny), where
Then you create a diamond inside this one which is smaller by the radius of the circle.
Then you test whether centre of the circle is between the four sides of this diamond: