java - Intercept between rectangle and line drawn from center point -
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
Post a Comment