add default vector implementation

As requested by sk89q in <https://github.com/SpongePowered/Sponge/pull/29>.
Indeed.  Thanks.
Yes, final modifier would do the trick.  All is well.


Date: Mon, 1 Dec 2014 14:10:15 -0800
From: notifications@github.com
To: SpongeAPI@noreply.github.com
CC: sibomots@outlook.com
Subject: Re: [SpongeAPI] add default vector implementation (#196)

In src/main/java/org/spongepowered/api/math/SpongeVector2d.java:

> +    }
> +
> +    @Override
> +    public double lengthSquared() {
> +        return x * x + y * y;
> +    }
> +
> +    @Override
> +    public double length() {
> +        return Math.sqrt(x * x + y * y);
> +    }
> +
> +    @Override
> +    public Vector2d normalize() {
> +        double length = Math.sqrt(x * x + y * y);
> +        return new SpongeVector2d(x / length, y / length);

@sibomots you seem to have missed my email, which explains that x and y are not volatile, and are in fact not mutable at all.


—
Reply to this email directly or view it on GitHub.

  
    
    
  
  
 		 	   		  =