Calculating a circle's center with two given positions and a direction in a 3D space

53 Views Asked by At

While programming a piece of software to mod a game, I have run into a mathematics problem I do not really know how to solve. I haven't got a mathematics background, which is the main reason why I don't know whether or not my question can even be solved with the given information, but I have tried my absolute best to make a good drawing to illustrate my problem and the desired outcome.

enter image description here

I have provided two examples in the drawing. In both examples, the player travels from A to B to C. These three points are marked with purple and their coordinates are all known. However, the desired outcome is not travelling from A to B to C, but instead from A to D, then from D to E in a circular pattern indicated with the blue arrow and then from E to C in a straight line again. To achieve this desired outcome, I will list the steps I had in mind. I do not really seem to know how to achieve these steps however, so I would really appreciate it if someone would like to explain to me how to do so (whoever does it by using my drawing deserves even more respect), but I also understand these steps might not be very straightforward and a bit out of the box, so I respect it if some people are deterred from assisting.

Step 1

The user in the software provides a distance, for example 30. The brown arrows indicate this distance in the example. The distance is used to calculate point D looking at A from B. In other words, point D is 30 units closer to A than B is. The same applies to point E being 30 units closer to C than B is.

Step 2

Once these two points have been calculated, I would have to figure out the center of the circle both of these points are a part of, however I understand that there are two possibilities here because only two points are given. In the software I suppose I could let the user provide the direction (left or right), but I think the coordinates should be able to tell me whether or not the direction is left or right (not sure, can anyone confirm?). The center of the circle is marked with a green circle, which is the intersection of the two green lines. My theory was that the intersection of the two perpendicular green lines would be the center of the circle, but this is a theory by a non-mathematician, so I cannot really confirm whether or not that's the right way to go about this. To give more context for these green lines, one line is perpendicular to the line between A and B and one green line is perpendicular to the line between B and C.

Step 3

I think I can handle it from there, because I have already created a script to calculate individual points along the blue line, currently only in 2D, but 3D shouldn't be too different I think. This script however expects the center of the circle to be a given, which in my problem now, isn't the case. If the angle between A, B and C is required for this rotation, this isn't a problem either because I have already got a script capable of calculating it.

As mentioned above, I perfectly understand this might not be a simple task and I respect it if people are discouraged to answer this question, but I would appreciate it ten times more if you could help me out because I'm a little bit at a loss.

Thank you very much. Jumper Snipèra