Browse Source

Docs: Vector2.

Mr.doob 13 years ago
parent
commit
dbc5a9386c
4 changed files with 122 additions and 206 deletions
  1. 106 5
      docs/api/core/Vector2.html
  2. 0 184
      docs/api/core/Vector2.rst
  3. 3 3
      docs/index.html
  4. 13 14
      src/core/Vector2.js

+ 106 - 5
docs/api/core/Vector2.html

@@ -1,23 +1,124 @@
 <h1>[name]</h1>
 
-<div class="desc">todo</div>
+<div class="desc">2D Vector</div>
+
+<h2>Example</h2>
+
+<code>var a = new THREE.Vector2( 0, 1 );
+var b = new THREE.Vector2( 1, 0 );
+
+var distance = a.distanceTo( b );
+</code>
 
 
 <h2>Constructor</h2>
 
-<h3>[name]()</h3>
+<h3>[name]( [page:Float x], [page:Float y] )</h3>
 
 
 <h2>Properties</h2>
 
-<h3>.[page:Vector3 todo]</h3>
+<h3>.[page:Float x]</h3>
+
+<h3>.[page:Float y]</h3>
 
 
 <h2>Methods</h2>
 
-<h3>.todo( [page:Vector3 todo] )</h3>
+<h3>.set( [page:Float x], [page:Float y] ) [page:Vector2]</h3>
+<div>
+Sets value of this vector.
+</div>
+
+<h3>.copy( [page:Vector2 v] ) [page:Vector2]</h3>
+<div>
+Copies value of *v* to this vector.
+</div>
+
+<h3>.add( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2]</h3>
+<div>
+Sets this vector to *a + b*.
+</div>
+
+<h3>.addSelf( [page:Vector2 v] ) [page:Vector2]</h3>
+<div>
+Adds *v* to this vector.
+</div>
+
+<h3>.sub( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2]</h3>
+<div>
+Sets this vector to *a - b*.
+</div>
+
+<h3>.subSelf( [page:Vector2 v] ) [page:Vector2]</h3>
+<div>
+Subtracts *v* from this vector.
+</div>
+
+<h3>.multiplyScalar( [page:Float s] ) [page:Vector2]</h3>
+<div>
+Multiplies this vector by scalar *s*.
+</div>
+
+<h3>.divideScalar( [page:Float s] ) [page:Vector2]</h3>
+<div>
+Divides this vector by scalar *s*.<br />
+Set vector to *( 0, 0 )* if *s == 0*.
+</div>
+
+<h3>.negate() [page:Vector2]</h3>
+<div>
+Inverts this vector.
+</div>
+
+<h3>.dot( [page:Vector2 v] ) [page:Float]</h3>
+<div>
+Computes dot product of this vector and *v*.
+</div>
+
+<h3>.lengthSq() [page:Float]</h3>
+<div>
+Computes squared length of this vector.
+</div>
+
+<h3>.length() [page:Float]</h3>
+<div>
+Computes length of this vector.
+</div>
+
+<h3>.normalize() [page:Vector2]</h3>
+<div>
+Normalizes this vector.
+</div>
+
+<h3>.distanceTo( [page:Vector2 v] ) [page:Float]</h3>
+<div>
+Computes distance of this vector to *v*.
+</div>
+
+<h3>.distanceToSquared( [page:Vector2 v] ) [page:Float]</h3>
+<div>
+Computes squared distance of this vector to *v*.
+</div>
+
+<h3>.setLength( [page:Float l] ) [page:Vector2]</h3>
+<div>
+Normalizes this vector and multiplies it by *l*.
+</div>
+
+<h3>.equals( [page:Vector2 v] ) [page:Vector2]</h3>
+<div>
+Checks for strict equality of this vector and *v*.
+</div>
+
+<h3>.isZero() [page:Vector2]</h3>
+<div>
+Checks if length of this vector is within small epsilon (*0.0001*).
+</div>
+
+<h3>.clone() [page:Vector2]</h3>
 <div>
-todo — todo<br />
+Clones this vector.
 </div>
 
 

+ 0 - 184
docs/api/core/Vector2.rst

@@ -1,184 +0,0 @@
-Vector2 - 2D vector
--------------------
-
-.. ...............................................................................
-.. rubric:: Constructor
-.. ...............................................................................
-
-.. class:: Vector2( x, y )
-
-    2D vector
-
-    :param float x: x-coordinate
-    :param float y: y-coordinate
-
-.. ...............................................................................
-.. rubric:: Attributes
-.. ...............................................................................
-
-.. attribute:: Vector2.x
-
-    float - default ``0``
-
-.. attribute:: Vector2.y
-
-    float - default ``0``
-
-.. ...............................................................................
-.. rubric:: Methods
-.. ...............................................................................
-
-.. function:: Vector2.clone( )
-
-    Clones this vector
-
-    :returns: New instance identical to this vector
-    :rtype: :class:`Vector2`
-
-.. function:: Vector2.set( x, y )
-
-    Sets value of this vector
-
-    :param float x: x-coordinate
-    :param float y: y-coordinate
-    :returns: This vector
-    :rtype: :class:`Vector2`
-
-.. function:: Vector2.copy( v )
-
-    Copies value of ``v`` to this vector
-
-    :param Vector2 v: source vector
-    :returns: This vector
-    :rtype: :class:`Vector2`
-
-.. function:: Vector2.add( v1, v2 )
-
-    Sets this vector to ``v1 + v2``
-
-    :param Vector2 v1: source vector 1
-    :param Vector2 v2: source vector 2
-    :returns: This vector
-    :rtype: :class:`Vector2`
-
-.. function:: Vector2.addSelf( v )
-
-    Adds ``v`` to this vector
-
-    :param Vector2 v: source vector
-    :returns: This vector
-    :rtype: :class:`Vector2`
-
-.. function:: Vector2.sub( v1, v2 )
-
-    Sets this vector to ``v1 - v2``
-
-    :param Vector2 v1: source vector 1
-    :param Vector2 v2: source vector 2
-
-.. function:: Vector2.subSelf( v )
-
-    Subtracts ``v`` from this vector
-
-    :param Vector2 v: source vector
-    :returns: This vector
-    :rtype: :class:`Vector2`
-
-.. function:: Vector2.multiplyScalar( s )
-
-    Multiplies this vector by scalar ``s``
-
-    :param float s: scalar
-    :returns: This vector
-    :rtype: :class:`Vector2`
-
-.. function:: Vector2.divideScalar( s )
-
-    Divides this vector by scalar ``s``
-
-    Set vector to ``( 0, 0 )`` if ``s == 0``
-
-    :param float s: scalar
-    :returns: This vector
-    :rtype: :class:`Vector2`
-
-.. function:: Vector2.negate( )
-
-    Inverts this vector
-
-    :returns: This vector
-    :rtype: :class:`Vector2`
-
-.. function:: Vector2.dot( v )
-
-    Computes dot product of this vector and ``v``
-
-    :returns: dot product
-    :rtype: float
-
-.. function:: Vector2.lengthSq( )
-
-    Computes squared length of this vector
-
-    :returns: squared length
-    :rtype: float
-
-.. function:: Vector2.length( )
-
-    Computes length of this vector
-
-    :returns: length
-    :rtype: float
-
-.. function:: Vector2.normalize( )
-
-    Normalizes this vector
-
-    :returns: This vector
-    :rtype: :class:`Vector2`
-
-.. function:: Vector2.distanceTo( v )
-
-    Computes distance of this vector to ``v``
-
-    :returns: squared distance
-    :rtype: float
-
-.. function:: Vector2.distanceToSquared( v )
-
-    Computes squared distance of this vector to ``v``
-
-    :returns: squared distance
-    :rtype: float
-
-.. function:: Vector2.setLength( l )
-
-    Normalizes this vector and multiplies it by ``l``
-
-    :returns: This vector
-    :rtype: :class:`Vector2`
-
-.. function:: Vector2.equals( v )
-
-    Checks for strict equality of this vector and ``v``
-
-    :returns: true if this vector equals ``v``
-    :rtype: boolean
-
-.. function:: Vector2.isZero( )
-
-    Checks if length of this vector is within small epsilon (``0.0001``)
-
-    :returns: true if this vector is zero
-    :rtype: boolean
-
-.. ...............................................................................
-.. rubric:: Example
-.. ...............................................................................
-
-::
-
-    var a = new THREE.Vector2( 0, 1 );
-    var b = new THREE.Vector2( 1, 0 );
-
-    var d = a.distanceTo( b );

+ 3 - 3
docs/index.html

@@ -350,11 +350,11 @@
 						
 						text = text.replace(/\[name\]/gi, name);
 						text = text.replace(/\[path\]/gi, path);
-						text = text.replace(/\[page:(\w+)\]/gi, "<a href=\"javascript:goTo('$1')\" title=\"$1\">$1</a>" ); // [page:name]
+						text = text.replace(/\[page:(\w+)\]/gi, "[page:$1 $1]" ); // [page:name] to [page:name title]
 						text = text.replace(/\[page:(\w+) ([\w|\.]+)\]/gi, "<a href=\"javascript:goTo('$1')\" title=\"$1\">$2</a>" ); // [page:name title]
-						text = text.replace(/\[link:([\w|\:|\/|\.|\-]+)\]/gi, "<a href=\"$1\" target=\"_blank\">$1</a>" ); // [link:url]
+						text = text.replace(/\[link:([\w|\:|\/|\.|\-]+)\]/gi, "[link:$1 $1" ); // [link:url] to [link:url title]
 						text = text.replace(/\[link:([\w|\:|\/|\.|\-]+) ([\w|\/|\.|\-]+)\]/gi, "<a href=\"$1\"  target=\"_blank\">$2</a>" ); // [link:url title]
-						text = text.replace(/\*([\w|\ |\-|\/]+)\*/gi, "<strong>$1</strong>" ); // *
+						text = text.replace(/\*([\w|\ |\-|\/|\+|\-|\(|\)|\=|\,|\.]+)\*/gi, "<strong>$1</strong>" ); // *
 
 						viewer.innerHTML = '<br>' + text + '<br><br>';
 

+ 13 - 14
src/core/Vector2.js

@@ -34,17 +34,10 @@ THREE.Vector2.prototype = {
 
 	},
 
-	clone: function () {
-
-		return new THREE.Vector2( this.x, this.y );
-
-	},
-
-
-	add: function ( v1, v2 ) {
+	add: function ( a, b ) {
 
-		this.x = v1.x + v2.x;
-		this.y = v1.y + v2.y;
+		this.x = a.x + b.x;
+		this.y = a.y + b.y;
 
 		return this;
 
@@ -59,10 +52,10 @@ THREE.Vector2.prototype = {
 
 	},
 
-	sub: function ( v1, v2 ) {
+	sub: function ( a, b ) {
 
-		this.x = v1.x - v2.x;
-		this.y = v1.y - v2.y;
+		this.x = a.x - b.x;
+		this.y = a.y - b.y;
 
 		return this;
 
@@ -105,7 +98,7 @@ THREE.Vector2.prototype = {
 
 	negate: function() {
 
-		return this.multiplyScalar( -1 );
+		return this.multiplyScalar( - 1 );
 
 	},
 
@@ -171,6 +164,12 @@ THREE.Vector2.prototype = {
 
 		return ( this.lengthSq() < 0.0001 /* almostZero */ );
 
+	},
+
+	clone: function () {
+
+		return new THREE.Vector2( this.x, this.y );
+
 	}
 
 };