updated
This commit is contained in:
parent
094d23b9ba
commit
3d74d9e5e0
|
@ -73,7 +73,7 @@ public class Vector2D implements IVector2D {
|
||||||
*/
|
*/
|
||||||
public void rescale() {
|
public void rescale() {
|
||||||
// calc unit vector and set it
|
// calc unit vector and set it
|
||||||
double vectorlength = Math.sqrt(Math.pow(getDx(), 2) + Math.pow(getDy(), 2));
|
double vectorlength = Math.sqrt(Math.pow(getDx(), 2) + Math.pow(getDy(), 2)); //using the square root of x and y
|
||||||
setDx((1/vectorlength) * getDx() * Constants.BALL_SPEED);
|
setDx((1/vectorlength) * getDx() * Constants.BALL_SPEED);
|
||||||
setDy((1/vectorlength) * getDy() * Constants.BALL_SPEED);
|
setDy((1/vectorlength) * getDy() * Constants.BALL_SPEED);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue