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

angular - DownloadURL return null in below code -

python 2.7 - Given three nested dictionaries, sort the top two nested dictionaries from a value in the innermost dictionary? -