Reputation: 813
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?
Upvotes: 0
Views: 941
Reputation: 6881
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.
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.
Upvotes: 3