0

I am in the process of creating an Android App which has an Image. The image has to circle around the center in the Elliptical path. I would require a function to return the X and Y coordinates of the Elliptical path. Could you please help me to achieve this?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
user1822729
  • 825
  • 1
  • 13
  • 27

1 Answers1

3

The below equations will give you x and y coordinates of ellipse.

x = a cos t 
y = b sin t

a - horizontal distance from origin.

b - vertical distance from origin

t - angle at which you need the coordinate. enter image description here

List<Double> xcoord = new ArrayList<Double>();
List<Double> ycoord = new ArrayList<Double>();

public void getCoordinates() {
    for(int i=0;i<360;i++) {
        xcoord.add(10 * Math.cos(i));
        ycoord.add(20 * Math.sin(i));
    }
}

The above function adds up all the coordinates from 0 to 360 to the list with 10 as horizontal distance from origin and 20 as vertical distance from origin. Hope this helps.

Vinay
  • 6,891
  • 4
  • 32
  • 50