Labs

var line = {
  x: 300,
  y: 200,
  length: 100,
  angle: 0
};
 
var ball = {
  x: 0,
  y: 0,
  vx: 2,
  vy: 3,
  r: 10
}
 
// ...
 
var triangle_x = ball.x - line.x;
var triangle_y = ball.y - line.y;
line.angle = Math.atan2(triangle_y, triangle_x);
 
var x = line.x + line.length * Math.cos(line.angle);
var y = line.y + line.length * Math.sin(line.angle);