How do i get the point of intersection of a line and a circle.. I got lots of information on this topic, but my requirement is not matching..
I got a line whose one end point lies at the origin of the circle.. and other end lies somewhere outside the circle.. Now i need the point of intersection of this line and circle..
I have tried to find closest edge point from outside the circle using below formula however unable to crack it -
closestCirclePoint = function(px, py, x, y, ray){
var tg = (x += ray, y += ray, 0);
return function(x, y, x0, y0){return Math.sqrt((x -= x0) * x + (y -= y0) * y);}(px, py, x, y) > ray ?
{x: Math.cos(tg = Math.atan2(py - y, px - x)) * ray + x, y: Math.sin(tg) * ray + y}
//{x: (px - x) / (length / ray) + x, y: (py - y) / (length / ray) + y}
: {x: px, y: py};
};
Any way to get the solution for this problem..?? Thanks in advance!