phetsims / pendulum-lab

"Pendulum Lab" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
4 stars 10 forks source link

Prefer usage of Vector2.setPolar #32

Closed jonathanolson closed 9 years ago

jonathanolson commented 9 years ago

Instead of the following:

this.accelerationVector.setXY( -accelerationMagnitude * Math.cos( accelerationAngle ), -accelerationMagnitude * Math.sin( accelerationAngle ) );

It's much simpler to call:

this.accelerationVector.setPolar( -accelerationMagnitude, accelerationAngle );
jonathanolson commented 9 years ago

This usage is in Pendulum.js, but please check for others.

andrey-zelenkov commented 9 years ago

Simplify code by using Vector2.setPolar instead of Vector2.setXY. Thank you for advice! Reassign to @jonathanolson for verification.

jonathanolson commented 9 years ago

Looks good, thanks!