Find a point on the circle of an ellipse that is inside a rectangle that has a center point, height and width?

I have a rectangle in .NET in which I draw an ellipse.

I know the width, height and center point of this rectangle.

Of course, the center point of the rectangle is also the center point of the ellipse.

I know how to calculate a point on a circle, however I have no idea about an ellipse.

I have these parameters and the angle, I need a point on the ellipse, can someone post the formula?

I saw somewhere that you need to calculate 2 points at which 2 radii will go, the sum of the radii will be fixed, and they will change accordingly.

I don’t know how to do this, I only have the height, width and center point of the rectangle and, of course, the angle at which I want to find the point.

thanks for any help Shlomi

+6
math geometry ellipse
source share
1 answer

You can use the canonical shape in polar coordinates for your problem, where the width and height of the rectangle are w and h respectively.

alt text

alt text

where t is the angle in radians, a is w / 2, and b is h / 2

So, to build your ellipse, everything you need to do varies from 0 to 360 degrees (in radians so that 0 and 2pi), and depending on how you exit t, you get points on the ellipse.

Since your rectangle is not centered at the origin, you will have to shift it along the coordinates of the center of the rectangle, say (C x , C y )

const double C_x = 10, C_y = 20, w = 40, h = 50; for(double t = 0; t <=2*pi; t+=0.01) { double X = C_x+(w/2)*cos(t); double Y = C_y+(h/2)*sin(t); // Do what you want with X & Y here } 
+13
source share

All Articles