Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. void SetupCircleParams() {
  2. Vector2 p1 = point1.anchoredPosition;
  3. Vector2 p2 = point2.anchoredPosition;
  4. Vector2 p3 = point3.anchoredPosition;
  5.  
  6. Vector2 v12 = p2 - p1;
  7. float ma = v12.y / v12.x;
  8. Vector2 v23 = p3 - p2;
  9. float mb = v23.y / v23.x;
  10.  
  11. float cx = ((ma * mb * (p1.y - p3.y)) + (mb * (p1.x + p2.x)) - (ma * (p2.x + p3.x))) / (2 * (mb - ma));
  12. float cy = ((-1f / ma) * (cx - ((p1.x + p2.x) / 2f))) + ((p1.y + p2.y) / 2f);
  13. circleCenter = new Vector2(cx, cy);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement