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?
Asked
Active
Viewed 899 times
1 Answers
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.
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
-
Mean time I got the same kinda solution. Thank you Buddy!. I have accepted your solution :) – user1822729 Feb 23 '13 at 04:20
-
@user1822729 what solution u got? – Amrut Bidri May 27 '15 at 11:32
-
this answer is cool. but what if the axis' have an inclination? how to do then? – Amrut Bidri May 28 '15 at 10:26
-
inclination? Didn't understand. Can you please explain – Vinay May 28 '15 at 10:28
-
http://www.codeproject.com/KB/miscctrl/EllipticPictureTray/Pic_Tray_mechanics.png – Amrut Bidri May 28 '15 at 11:00