Limit the magnitude of this vector to the value used for the max parameter. @webref pvector:method @usage web_application @param max the maximum magnitude for the vector @webBrief Limit the magnitude of the vector
(float max)
| 808 | * @webBrief Limit the magnitude of the vector |
| 809 | */ |
| 810 | public PVector limit(float max) { |
| 811 | if (magSq() > max*max) { |
| 812 | normalize(); |
| 813 | mult(max); |
| 814 | } |
| 815 | return this; |
| 816 | } |
| 817 | |
| 818 | |
| 819 | /** |