ClassyGoat
Member
Hello!
So I'm trying to write a formula to find all the squares on a grid system that are within a defined ellipse shape. Attached is an image showing an example of this: The blue squares represent all the squares that are fully within the ellipse.
I've got one that works for perfect circles, which is:
But I need to be able to do this with an ellipse where the major and minor axis are different sizes.
I did find this online, which might do what I want, but I'm having a hard time converting the code to GML: http://people.sc.fsu.edu/~jburkardt/cpp_src/ellipse_grid/ellipse_grid.html
Any and all help with this would be greatly appreciated!
So I'm trying to write a formula to find all the squares on a grid system that are within a defined ellipse shape. Attached is an image showing an example of this: The blue squares represent all the squares that are fully within the ellipse.
I've got one that works for perfect circles, which is:
Code:
cell_size = 24; // Each square is 24 x 24 pixels.
var _radius = 6; // Change be changed to anything
{
for (var _y = -_radius; _y <= _radius; _y++)
for (var _x = -_radius; _x <= _radius; _x++)
if ((_x * _x) + (_y * _y) <= (_radius * _radius)){
draw_sprite( spr_square, 0, _x * cell_size, _y * cell_size ); // Draws "spr_square" at every square within circle.
}
}
I did find this online, which might do what I want, but I'm having a hard time converting the code to GML: http://people.sc.fsu.edu/~jburkardt/cpp_src/ellipse_grid/ellipse_grid.html
Any and all help with this would be greatly appreciated!
Attachments
-
37.9 KB Views: 2