Calculate coincident between two spheres

Godot Version

4.3

Question

Hi all,

I am trying to pretty up a curve by following a bend radius but I am getting stuck on calculating the appropriate angle to be a good coincident line or rather the point where the bend exits the sphere rotation pictured in the purple circles in the image supplied.

What I have is a start point and a end point as a Vector3 both also have an direction Vector3. I then calculate the direction_to between the two points and map them to their direction planes to get the location of the pivot shown as green spheres. I then create a quaternion to rotate a vertex round the pivot from the start or end point based on the angle between the point direction and the direction_to and add them to the curve.

The problem is that when I create the second pivot it gets the direction to the last vertex created by the first pivot operation which creates a really nice appropriate curve but the first pivot direction was to the end point and not the last vertex created for the second pivot operation which causes it to intersect the sphere. Not I can go back and forth a couple times to refine the shape but that feels kinda dirty and I would much rather calculate the appropriate angle the first time round.

Any advise on that matter would be greatly appreciated

1 Like

Commenting for the sake of bumping the thread up. I could foresee trying this one day too and would like input from someone who knows.

I have figured it out.

the following code will give you the correct angle to give to the quaternion for the appropriate bend. I confirmed it by trying it on the second pivot and it spit out the exactly the same angle

(start_position + start_direction * radius).direction_to((end_position + end_direction * radius)).angle_to(start_direction)
1 Like