Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //wrap around so it cannot get too far away
- //get the vector from dla_center to current_circle
- PVector center_to_circle = PVector.sub(current_circle,dla_center);
- float sq_dist = sq(center_to_circle.x)+sq(center_to_circle.y);
- if(sq_dist > bound_radius_sq) {
- float prev_dist = sqrt(sq_dist);
- //make the distance outside of the radius into the amount inside
- //bound_radius-(prev_dist-bound_radius)
- float new_dist = 2*bound_radius-prev_dist;
- center_to_circle.mult(-new_dist/prev_dist);
- current_circle.x = center_to_circle.x+dla_center.x;
- current_circle.y = center_to_circle.y+dla_center.y;
- }
Add Comment
Please, Sign In to add comment