java - Intercept between rectangle and line drawn from center point -


consider following diagram enter image description here

given center point of rectangle , origin, , coordinates b, how find @ point line ab intersects rectangle? thanks.

intersection coordinates relative center (a point):

dx = b.x - a.x dy = b.y - a.y if width * abs(dy) < height * abs(dx)    x = sign(dx) * width / 2    y = dy * x / dx else    y = sign(dy) * height / 2    x = dx * y / dy 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -