Original Post
Is the equation the same as the code shown? x1 and y1 are the location of the circle. x2 and y2 are the coordinates produced by the equation Equation: http://mathworld.wolfram.com/CircleTangentLine.html
int xs = x1*x1;
int ys = y1*y1;
int rs = r*r;
double t = Math.Acos( ((-r*x1) + (y1*Math.Sqrt( xs + ys - rs ))) / (xs + ys) );
double t2 = -Math.Acos( ((-r*x1) + (y1*Math.Sqrt( xs + ys - rs ))) / (xs + ys) );
double t3 = -Math.Acos( ((-r*x1) - (y1*Math.Sqrt( xs + ys - rs ))) / (xs + ys) );
double t4 = Math.Acos( ((-r*x1) - (y1*Math.Sqrt( xs + ys - rs ))) / (xs + ys) );
if( x1 < 0 )
{
if( y1 > 0 )
{
x2 = (float)( x1 + 45*Math.Cos(t3) );
y2 = (float)( y1 + 45*Math.Sin(t3) );
}
else
{
x2 = (float)( x1 + 45*Math.Cos(t) );
y2 = (float)( y1 + 45*Math.Sin(t) );
}
}
else if( x1 >= 0 )
{
if( y1 > 0 )
{
x2 = (float)( x1 + 45*Math.Cos(t) );
y2 = (float)( y1 + 45*Math.Sin(t) );
}
else
{
x2 = (float)( x1 + 45*Math.Cos(t) );
y2 = (float)( y1 + 45*Math.Sin(t) );
}
}
