Question

Now i draw pictures in circle by formula :

     float x = CIRCLE_RADIUS *  (float) Math.sin(2f * Math.PI * drawSquareIndex / ITEMS_COUNT + angle) * 1.75f;

where x - is a X point of circle item.

And i have a circle.

enter image description here

but i want to draw pictures on ellipse. What the formula i need to use?

enter image description here

How i can do that?

P.S. sorry about quality. Make a question from phone.

Was it helpful?

Solution

You can use parametric ellipse equaition (a = b is a case of cirle):

x = a * cos(t)
y = b * sin(t)
t = 0..2*PI

In your case

  // Pseudo code
  for (double t = 0; t < 2 * PI; t += 0.001) { // <- or different step
    double x = RadiusX * Math.Cos(t);
    double y = RadiusY * Math.Sin(t);

    Paint(x, y);
  }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top