Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (a, b) = corner1 (coordinates of the side of the rectangle)
- (c, d) = corner2
- len = sqrt[(a - c)^2 + (b - d)^2]
- ac' = (a - c) / len
- bd' = (b - d) / len
- dotProduct = x1*ac' + x2*bd'
- xp = dotProduct * ac'
- yp = dotProduct * bd'
- xr = x1 - xp
- yr = y1 - yp
- x2 = xr - xp
- y2 = yr - xp
Add Comment
Please, Sign In to add comment