0
\$\begingroup\$

I'm trying to understand how to calculate the midpoint of a turning circle. In the attached picture, my unit is at location U. I want to compute the trajectory of the unit as it turns toward the starred location.

I understand that to achieve this I need to know the location of point P, whose coordinates are (a,b). I also understand that I can do this using some simple trig:

a = x - cos(theta) * r
b = y - sin(theta) * r

My problem is that I do not know the value of the angle Theta which sits between the sides of the right-triangle named "R" and "X-A". All I know is:

  1. The radius of the turning circle.

  2. The orientation of the unit.

How can I solve this problem and others like it more generally?

enter image description here

\$\endgroup\$

3 Answers 3

0
\$\begingroup\$

Question details keep on changing, so I'll post 3 different answers covering all of them

So you know the radius R and unit location U and facing direction F.

  • normalize the unit direction F
  • make a perpendicular to F (you need to pick from 2 directions, pick one that is closer to units target), we call it F2
  • multiply perpendicular F2 with radius R, (call it F2R)
  • take location of the unit U and add multiplied perpendicular F2R to it
  • that's your circle midpoint P.

enter image description here

\$\endgroup\$
0
\$\begingroup\$

Question details keep on changing, so I'll post 3 different answers covering all of them

If you know only unit location U and turning circle radius R

This can not be done distinctively if the only things you know are the location U and circle radius R.

Take a look at illustration below:

enter image description here

There is infinity of circles with radius R around the unit location U. You need a rule of picking only one of those turning circles (e.g. unit facing direction will eliminate all but 2 circles and you drop one that is farther from target location).

\$\endgroup\$
0
\$\begingroup\$

Question details keep on changing, so I'll post 3 different answers covering all of them

If we know unit location U, circle radius R and target location S

Here's a generic approach to the case. Let's try to parametrize it now.

  • Find a point in between Star and U - that is our MidPoint.
  • Make a perpendicular from that point (you might want to have it facing against unit movement vector).
  • Now, that MidPoint + Offset in the direction is the center of your circle. (Note that Radius cannot be smaller than half the distance between Star and U.)
  • Now we need to find an Offset that will make the circle Radius that you need. As you see we have a right triangle between circle center (P), Star (S) and MidPoint (M).
  • From the math class: MS^2 + MP^2 = PS^2.
  • MP = Sqrt(PS^2 - MS^2)
  • Knowing MP length it's a matter of math to find coordinates (a,b) of P

enter image description here

\$\endgroup\$
11
  • \$\begingroup\$ Hi Krom, The position of the starred location is initially unknown. I guess I should have omitted it entirely from the diagram. The unit will decide, at some stage, to stop turning and move toward its target. The target can be anywhere; not necessarily on the perimeter of the circle. \$\endgroup\$
    – confused
    Sep 3, 2014 at 5:01
  • \$\begingroup\$ Without knowing Star location, you have just a U and Radius. These 2 are not enough to make a circle. \$\endgroup\$
    – Kromster
    Sep 3, 2014 at 5:11
  • \$\begingroup\$ The radius "r" defines the circle. I want to know its midpoint so I can visualise the path my agent will take when turning. \$\endgroup\$
    – confused
    Sep 3, 2014 at 5:19
  • \$\begingroup\$ Once again, if you have only U and Radius, there is infinity of circles of that radius around U. Take a piece of paper, place a point U, now draw multitude of lines from U with length R into all directions. End of each line is a center of circle with radius R and point U on it. \$\endgroup\$
    – Kromster
    Sep 3, 2014 at 5:22
  • \$\begingroup\$ There seems to be some misunderstanding here. As far as I can see there are only two turning circles, depending on whether the unit is turning left or right. In the example I give, the unit is turning left, toward the starred location. \$\endgroup\$
    – confused
    Sep 3, 2014 at 5:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .