I want to calculate x,y coordinates of point on orbit. I have radius (for example 1), coordinates of center of orbit (0,0) and the time it takes to make full circle on orbit (for example 2), starting coordinates of object(-radius,0), and I want to calculate x and y after 1 day, so it should be on radius,0. But how to calculate it without angle?
You're going to have to start by translating the the orbit into a rotation rate, which will give you an equation for θ(t)
, where t
and θ(t)
is the angle (normally in radians) in the orbit at time t
. The position would then be given by
X ← r·cos(θ(t)) + x0
Y ← r·sin(θ(t)) + y0
where r
is the radius of your orbit (which you indicated was 1
) and (x0, y0)
is the center of the orbit (which you indicated was (0,0)
).
If you want the point to have a constant rotation rate and arrive at (r, 0)
after exactly 1
day, then your θ(t)
would be a function of the form:
θ(t) ← 2·n·π·t + θ(0)
Where t
is time in days and n
is an integer value. θ(0)
is just the starting angle which in your case will be π
. There are an infinite number of other such functions which could permit this to occur if you wanted to use a non-constant rotation rate, but you would need to provide some additional requirements for that.
A more general function will permit you to specify the constant rotation rate α
and calculate the angle at a time t
. This would take on the form
θ(α, t) ← 2·α·π·t + θ(0)
So in your example of a rotation rate of 2
, θ(2, t) = 4·π·t
Coding this in Java is left as an exercise to the reader.