Sudha247 / ocaml-joy

MIT License
22 stars 14 forks source link

Difficulty in rotating shapes with current rectangle representation #59

Closed nikochiko closed 7 months ago

nikochiko commented 1 year ago

With the current representation of ellipse/rectangles, there's no way to rotate them. This is a problem, and we should correct for it.

We can keep the API the same but change the representation internally so that we can then rotate these shapes.

I'm thinking that we should use a general Polygon shape that would keep track of all points of the shape. In the rectangle constructor, we can calculate these initial points from the center, width, and height.

Rotating the ellipse would still be hard because the graphics library doesn't have an API that would account for its rotation. https://v2.ocaml.org/releases/4.03/htmlman/libref/Graphics.html

nikochiko commented 1 year ago

The problem is that the current rectangle representation only has a center, width, and height. It doesn't have room for information about its orientation.

Polygon as a collection of points is a general solution that will work with other polygons too.

@Sudha247 @AryanGodara

nangahamandine commented 11 months ago

With the current representation of ellipse/rectangles, there's no way to rotate them. This is a problem, and we should correct for it.

We can keep the API the same but change the representation internally so that we can then rotate these shapes.

I'm thinking that we should use a general Polygon shape that would keep track of all points of the shape. In the rectangle constructor, we can calculate these initial points from the center, width, and height.

Rotating the ellipse would still be hard because the graphics library doesn't have an API that would account for its rotation. https://v2.ocaml.org/releases/4.03/htmlman/libref/Graphics.html

Hi @nikochiko, @Sudha247, @AryanGodara

I have two propositions regarding the representation for the ellipse, it's rotation and complexity.