# Is there a better way to do this?

This topic is 2835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

[font="Calibri"][size="3"][color="#000000"]I have been working on trying to get an implementation of reciprocal obstacle avoidance working.[/font]

[size="3"][color="#000000"][font="Calibri"]I need to find the point tangent to a circle from the origin (0,0). I know how to do this using two circles kind of like the diagram below. I was planning to us the quadratic equation to find the two tangents[/font] [font="Calibri"]points.[/font]
[font="Calibri"][size="3"][color="#000000"]http://www.nvcc.edu/home/tstreilein/constructions/Circle/circle5.htm[/font]
[font="Calibri"][size="3"][color="#000000"]I need both tangent points[/font]
[font="Calibri"][size="3"][color="#000000"]I know[/font]
[font="Calibri"][size="3"][color="#000000"]1: circle center [/font]
[font="Calibri"][size="3"][color="#000000"]3: And that the tangent points must pass through the origin (0,0).[/font]
[font="Calibri"][color="#000000"][size="3"]I have not used much trig in many years. I[size="3"][font="Times New Roman"]s there [/font]a better trigonometry based way? I know how to find the lengths of all sides and the interior angles. But not how to find the tangent points. [/font]

##### Share on other sites
Ok so I forgot that slope = tan(angle) . What way do you think is better trig or not ?

##### Share on other sites
Hi Normalized,

Since the tangent is always perpendicular to the line through the center of the circle and the point where the tangent touches the circle, you're dealing with a right angled triangle where you know the hypotenuse (distance from the origin to the center of the circle) and one of the sides (the radius of the circle). So the line segment from the origin to the tangent point on the circle has a length of

L = sqrt(H^2 - R^2)

where H is the length of the line from the origin to the center of the circle and R is the radius of the circle. The angle between the tangent and the line from the origin to the center of the circle is

theta = asin(R/H)

So you can create a vector of length L that is parallel to line from the origin to the center of the circle, and rotate it by +/- theta to get the tangent points.

-Josh

##### Share on other sites
Hidden
asin(0.87 / 0.2) = NAN

How do you deal with that? its outside the range of asin.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 21
• 23
• 11
• 25