Sudha247 / ocaml-joy

MIT License
22 stars 14 forks source link

Suggestions on how to improve the present ellipse representation. #73

Closed nangahamandine closed 6 months ago

nangahamandine commented 10 months ago

I created this issue so that we the applicants and any other kind contributor could have a discussion to figure out how to improve upon the present ellipse representation.

As we all know, with the current representation of the ellipse/rectangle, it's difficult to rotate them and will definitely be difficult to perform other complex transformation with them. This is an issue that needs to be resolved so that we could proceed with recording other valuable contributions. One of us did a great job to rectify the issue with the rectangle but the ellipse still needs to be updated.

Rotating the ellipse has been hard because the graphics library doesn't have an API that would account for its rotation as you can see below: https://v2.ocaml.org/releases/4.03/htmlman/libref/Graphics.html

I've been giving this some thought and had two suggestions, which might not be the best and most feasible approaches since we are trying to keep the API as simple and as clean as possible. The suggestions are as follows:

Can we all please collaborate and chip in our ideas to see how we can resolve this issue? I'm avoiding to tag anyone because I don't want to spam. We're all doing great with contributing to the API so far so I'm sure we could collaboratively tackle this with no issues. :)

TitilayoAdeyemi commented 10 months ago

Hey Nangah! How do you plan to go about the matrix transformation? I've never done something like that before, it actually sounds kinda complex:sweat_smile: but I'm interested in it and open to learning What does it involve?

nangahamandine commented 10 months ago

I've done something similar before with Python, but not with OCaml. Generally in computer graphics, matrix transformations are used to manipulate the position, orientation, and scaling of objects. So a 2D transformation matrix is a 2x2 matrix used for transforming 2D points, therefore this could be applied to transformations such as translation, rotation, and scaling.

To apply this to the ellipse rotation, we'll primarily use a rotation matrix. We'll definitely need to modify the rotate function for ellipses in the code, calculate the rotated coordinates for each point on the ellipse using the rotation matrix and then use the rotate_ellipse function to rotate the ellipse.

This is basically what my thoughts are. I'd like to know everyone else's thoughts before we could proceed with applying this.