Guest User

Untitled

a guest
May 25th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. //wrap around so it cannot get too far away
  2. //get the vector from dla_center to current_circle
  3. PVector center_to_circle = PVector.sub(current_circle,dla_center);
  4. float sq_dist = sq(center_to_circle.x)+sq(center_to_circle.y);
  5. if(sq_dist > bound_radius_sq) {
  6. float prev_dist = sqrt(sq_dist);
  7. //make the distance outside of the radius into the amount inside
  8. //bound_radius-(prev_dist-bound_radius)
  9. float new_dist = 2*bound_radius-prev_dist;
  10. center_to_circle.mult(-new_dist/prev_dist);
  11. current_circle.x = center_to_circle.x+dla_center.x;
  12. current_circle.y = center_to_circle.y+dla_center.y;
  13. }
Add Comment
Please, Sign In to add comment