Created
May 13, 2010 16:12
-
-
Save nervoussystem/400005 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment