Line wrapping and line ending cleanup

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@800 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Tom Conkling
2009-03-31 22:29:18 +00:00
parent 126e58ac11
commit e9a797fef2
+53 -53
View File
@@ -51,7 +51,7 @@ public class Vector2
{ {
return new Vector2(t.x - s.x, t.y - s.y); return new Vector2(t.x - s.x, t.y - s.y);
} }
/** /**
* Creates a Vector2 of magnitude 'len' that has been rotated about the origin by 'radians'. * Creates a Vector2 of magnitude 'len' that has been rotated about the origin by 'radians'.
*/ */
@@ -64,17 +64,17 @@ public class Vector2
Math.sin(radians) * len); // == len * (sin(theta)*x + cos(theta)*y) Math.sin(radians) * len); // == len * (sin(theta)*x + cos(theta)*y)
} }
/** /**
* Constructs a Vector2 from the given values. * Constructs a Vector2 from the given values.
*/ */
public function Vector2 (x :Number = 0, y :Number = 0) public function Vector2 (x :Number = 0, y :Number = 0)
{ {
this.x = x; this.x = x;
this.y = y; this.y = y;
} }
/** /**
* Sets the vector's components to the given values. * Sets the vector's components to the given values.
*/ */
public function set (x :Number, y :Number) :void public function set (x :Number, y :Number) :void
{ {
@@ -82,8 +82,8 @@ public class Vector2
this.y = y; this.y = y;
} }
/** /**
* Returns the dot product of this vector with vector v. * Returns the dot product of this vector with vector v.
*/ */
public function dot (v :Vector2) :Number public function dot (v :Vector2) :Number
{ {
@@ -98,16 +98,16 @@ public class Vector2
return new Point(x, y); return new Point(x, y);
} }
/** /**
* Returns a copy of this Vector2. * Returns a copy of this Vector2.
*/ */
public function clone () :Vector2 public function clone () :Vector2
{ {
return new Vector2(x, y); return new Vector2(x, y);
} }
/** /**
* Returns the angle represented by this Vector2, in radians. * Returns the angle represented by this Vector2, in radians.
*/ */
public function get angle () :Number public function get angle () :Number
{ {
@@ -115,34 +115,34 @@ public class Vector2
return (angle >= 0 ? angle : angle + (2 * Math.PI)); return (angle >= 0 ? angle : angle + (2 * Math.PI));
} }
/** /**
* Returns this vector's length. * Returns this vector's length.
*/ */
public function get length () :Number public function get length () :Number
{ {
return Math.sqrt(x * x + y * y); return Math.sqrt(x * x + y * y);
} }
/** /**
* Sets this vector's length. * Sets this vector's length.
*/ */
public function set length (newLen :Number) :void public function set length (newLen :Number) :void
{ {
var scale :Number = newLen / this.length; var scale :Number = newLen / this.length;
x *= scale; x *= scale;
y *= scale; y *= scale;
} }
/** /**
* Returns the square of this vector's length. * Returns the square of this vector's length.
*/ */
public function get lengthSquared () :Number public function get lengthSquared () :Number
{ {
return (x * x + y * y); return (x * x + y * y);
} }
/** /**
* Rotates the vector in place by 'radians'. * Rotates the vector in place by 'radians'.
* Returns a reference to 'this', for chaining. * Returns a reference to 'this', for chaining.
*/ */
@@ -154,34 +154,34 @@ public class Vector2
var oldX :Number = x; var oldX :Number = x;
x = (cosTheta * oldX) - (sinTheta * y); x = (cosTheta * oldX) - (sinTheta * y);
y = (sinTheta * oldX) + (cosTheta * y); y = (sinTheta * oldX) + (cosTheta * y);
return this; return this;
} }
/** /**
* Returns a rotated copy of this vector. * Returns a rotated copy of this vector.
*/ */
public function rotate (radians :Number) :Vector2 public function rotate (radians :Number) :Vector2
{ {
return this.clone().rotateLocal(radians); return this.clone().rotateLocal(radians);
} }
/** /**
* Normalizes the vector in place and returns its original length. * Normalizes the vector in place and returns its original length.
*/ */
public function normalizeLocalAndGetLength () :Number public function normalizeLocalAndGetLength () :Number
{ {
var length :Number = this.length; var length :Number = this.length;
x /= length; x /= length;
y /= length; y /= length;
return length; return length;
} }
/** /**
* Normalizes this vector in place. * Normalizes this vector in place.
* Returns a reference to 'this', for chaining. * Returns a reference to 'this', for chaining.
*/ */
public function normalizeLocal () :Vector2 public function normalizeLocal () :Vector2
{ {
@@ -189,19 +189,19 @@ public class Vector2
x *= lengthInverse; x *= lengthInverse;
y *= lengthInverse; y *= lengthInverse;
return this; return this;
} }
/** /**
* Returns a normalized copy of the vector. * Returns a normalized copy of the vector.
*/ */
public function normalize () :Vector2 public function normalize () :Vector2
{ {
return this.clone().normalizeLocal(); return this.clone().normalizeLocal();
} }
/** /**
* Adds another Vector2 to this, in place. * Adds another Vector2 to this, in place.
* Returns a reference to 'this', for chaining. * Returns a reference to 'this', for chaining.
*/ */
@@ -209,11 +209,11 @@ public class Vector2
{ {
x += v.x; x += v.x;
y += v.y; y += v.y;
return this; return this;
} }
/** /**
* Returns a copy of this vector added to 'v'. * Returns a copy of this vector added to 'v'.
*/ */
public function add (v :Vector2) :Vector2 public function add (v :Vector2) :Vector2
@@ -221,7 +221,7 @@ public class Vector2
return this.clone().addLocal(v); return this.clone().addLocal(v);
} }
/** /**
* Subtracts another vector from this one, in place. * Subtracts another vector from this one, in place.
* Returns a reference to 'this', for chaining. * Returns a reference to 'this', for chaining.
*/ */
@@ -229,12 +229,12 @@ public class Vector2
{ {
x -= v.x; x -= v.x;
y -= v.y; y -= v.y;
return this; return this;
} }
/** /**
* Returns (this - v). * Returns (this - v).
*/ */
public function subtract (v :Vector2) :Vector2 public function subtract (v :Vector2) :Vector2
{ {
@@ -242,9 +242,9 @@ public class Vector2
} }
/** /**
* Returns a vector that is perpendicular to this. * Returns a vector that is perpendicular to this one.
* If ccw = true, the perpendicular vector is rotated 90 degrees counter-clockwise from this vector, * If ccw = true, the perpendicular vector is rotated 90 degrees counter-clockwise from this
* otherwise it's rotated 90 degrees clockwise. * vector, otherwise it's rotated 90 degrees clockwise.
*/ */
public function getPerp (ccw :Boolean = true) :Vector2 public function getPerp (ccw :Boolean = true) :Vector2
{ {
@@ -262,7 +262,7 @@ public class Vector2
{ {
x *= value; x *= value;
y *= value; y *= value;
return this; return this;
} }
@@ -279,29 +279,29 @@ public class Vector2
{ {
x = -x; x = -x;
y = -y; y = -y;
return this; return this;
} }
/** /**
* Returns a copy of the vector, inverted. * Returns a copy of the vector, inverted.
*/ */
public function invert () :Vector2 public function invert () :Vector2
{ {
return this.clone().invertLocal(); return this.clone().invertLocal();
} }
/** /**
* Returns true if this vector is equal to v. * Returns true if this vector is equal to v.
*/ */
public function equals (v :Vector2) :Boolean public function equals (v :Vector2) :Boolean
{ {
return (x == v.x && y == v.y); return (x == v.x && y == v.y);
} }
/** /**
* Returns true if the components of v are equal to the components of this Vector2, * Returns true if the components of v are equal to the components of this Vector2,
* within the given epsilon. * within the given epsilon.
*/ */
public function similar (v :Vector2, epsilon :Number) :Boolean public function similar (v :Vector2, epsilon :Number) :Boolean
{ {