Guest User

Untitled

a guest
Jul 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. (a, b) = corner1 (coordinates of the side of the rectangle)
  2. (c, d) = corner2
  3.  
  4. len = sqrt[(a - c)^2 + (b - d)^2]
  5.  
  6. ac' = (a - c) / len
  7. bd' = (b - d) / len
  8.  
  9. dotProduct = x1*ac' + x2*bd'
  10.  
  11. xp = dotProduct * ac'
  12. yp = dotProduct * bd'
  13.  
  14. xr = x1 - xp
  15. yr = y1 - yp
  16.  
  17. x2 = xr - xp
  18. y2 = yr - xp
Add Comment
Please, Sign In to add comment