Hi guys,
Given two points A,B that move at constant velocities Va, Vb, two spheres(Sa,Sb) that orbit these points at constant angular velocities(Ca, Cb) with orbit radius Oa, Ob, I am trying to calculate whether the spheres collide and if yes, the time till first collision.
My take on this problem:
I can simplify this problem by subtracting velocity Vb from both points to get relative velocity
Thus, point A's relative velocity to B is (Va-Vb), and B's relative velocity (Vb-Vb) = 0
Attempt:
My idea was to create a function f(t) that will represent A's trajectory over time.
I have found such function in 2D:
f(t).x = A.x+Va.x*t+Oa*cos(W+Ca*t)
f(t).y = A.y+Va.y*t+Oa*sin(W+Ca*t)
B's trajectory g(t) can be represented by circle:
g(t).x = B.x+Ob*cos(Z+Cb*t)
g(t).y = B.y+Ob*sin(Z+Cb*t)
//W and Z are offsets, I think they can be calculated from the A and Sa positions for W, and B, Sb for Z respectively
Then I use the distance formula:
d = sqrt( (f(t).x-g(t).x)^2 + (f(t).y-g(t).y)^2)
The two spheres touch when they distance between them is the sum of their radius, thus:
Sa.radius+Sb.radius = sqrt( (f(t).x-g(t).x)^2 + (f(t).y-g(t).y)^2))
(Sa.radius+Sb.radius)^2 = (f(t).x-g(t).x)^2 + (f(t).y-g(t).y)^2)
However, from here on I do not know how to solve this, there is only one unknown variable t.
I don't know how to solve this because of the sin and cos that contain the unknown t.
I would like to know your opinion on my approach, is it a good way to solve the problem in 3D as well, and whether you know any other solution.
Thanks for help.
ps: here is an example of a sphere and trajectory it can take when orbiting around a moving point

Given two points A,B that move at constant velocities Va, Vb, two spheres(Sa,Sb) that orbit these points at constant angular velocities(Ca, Cb) with orbit radius Oa, Ob, I am trying to calculate whether the spheres collide and if yes, the time till first collision.
My take on this problem:
I can simplify this problem by subtracting velocity Vb from both points to get relative velocity
Thus, point A's relative velocity to B is (Va-Vb), and B's relative velocity (Vb-Vb) = 0
Attempt:
My idea was to create a function f(t) that will represent A's trajectory over time.
I have found such function in 2D:
f(t).x = A.x+Va.x*t+Oa*cos(W+Ca*t)
f(t).y = A.y+Va.y*t+Oa*sin(W+Ca*t)
B's trajectory g(t) can be represented by circle:
g(t).x = B.x+Ob*cos(Z+Cb*t)
g(t).y = B.y+Ob*sin(Z+Cb*t)
//W and Z are offsets, I think they can be calculated from the A and Sa positions for W, and B, Sb for Z respectively
Then I use the distance formula:
d = sqrt( (f(t).x-g(t).x)^2 + (f(t).y-g(t).y)^2)
The two spheres touch when they distance between them is the sum of their radius, thus:
Sa.radius+Sb.radius = sqrt( (f(t).x-g(t).x)^2 + (f(t).y-g(t).y)^2))
(Sa.radius+Sb.radius)^2 = (f(t).x-g(t).x)^2 + (f(t).y-g(t).y)^2)
However, from here on I do not know how to solve this, there is only one unknown variable t.
I don't know how to solve this because of the sin and cos that contain the unknown t.
I would like to know your opinion on my approach, is it a good way to solve the problem in 3D as well, and whether you know any other solution.
Thanks for help.
ps: here is an example of a sphere and trajectory it can take when orbiting around a moving point
