提交 7e45066f 编写于 作者: W WestLangley 提交者: Mr.doob

Added Manhattan distance (#9206)

上级 a88d56aa
......@@ -126,17 +126,17 @@
<h3>[method:Float lengthSq]() [page:Vector2 this]</h3>
<div>
Computes squared length of this vector.
Computes the squared length of this vector.
</div>
<h3>[method:Float length]() [page:Vector2 this]</h3>
<div>
Computes length of this vector.
Computes the length of this vector.
</div>
<h3>[method:Float lengthManhattan]() [page:Vector2 this]</h3>
<div>
Computes Manhattan length of this vector.<br />
Computes the Manhattan length of this vector.<br />
[link:http://en.wikipedia.org/wiki/Taxicab_geometry]
</div>
......@@ -152,12 +152,17 @@
<h3>[method:Float distanceTo]( [page:Vector2 v] )</h3>
<div>
Computes distance of this vector to *v*.
Computes the distance from this vector to *v*.
</div>
<h3>[method:Float distanceToSquared]( [page:Vector2 v] )</h3>
<div>
Computes squared distance of this vector to *v*.
Computes the squared distance from this vector to *v*.
</div>
<h3>[method:Float distanceToManhattan]( [page:Vector2 v] )</h3>
<div>
Computes the Manhattan distance from this vector to *v*.
</div>
<h3>[method:Vector2 setLength]( [page:Float l] ) [page:Vector2 this]</h3>
......
......@@ -130,17 +130,17 @@
<h3>[method:Float lengthSq]() [page:Vector3 this]</h3>
<div>
Computes squared length of this vector.
Computes the squared length of this vector.
</div>
<h3>[method:Float length]() [page:Vector3 this]</h3>
<div>
Computes length of this vector.
Computes the length of this vector.
</div>
<h3>[method:Float lengthManhattan]() [page:Vector3 this]</h3>
<div>
Computes Manhattan length of this vector.<br />
Computes the Manhattan length of this vector.<br />
[link:http://en.wikipedia.org/wiki/Taxicab_geometry]
</div>
......@@ -149,14 +149,19 @@
Normalizes this vector. Transforms this Vector into a Unit vector by dividing the vector by its length.
</div>
<h3>[method:Float distanceTo]( [page:Vector3 v] ) [page:Vector3 this]</h3>
<h3>[method:Float distanceTo]( [page:Vector3 v] )</h3>
<div>
Computes distance of this vector to *v*.
Computes the distance from this vector to *v*.
</div>
<h3>[method:Float distanceToSquared]( [page:Vector3 v] ) [page:Vector3 this]</h3>
<h3>[method:Float distanceToSquared]( [page:Vector3 v] )</h3>
<div>
Computes squared distance of this vector to *v*.
Computes the squared distance from this vector to *v*.
</div>
<h3>[method:Float distanceToManhattan]( [page:Vector3 v] )</h3>
<div>
Computes the Manhattan distance from this vector to *v*.
</div>
<h3>[method:Vector3 setLength]( [page:Float l] ) [page:Vector3 this]</h3>
......
......@@ -137,12 +137,18 @@
<h3>[method:Float lengthSq]() [page:Vector4 this]</h3>
<div>
Computes squared length of this vector.
Computes the squared length of this vector.
</div>
<h3>[method:Float length]() [page:Vector4 this]</h3>
<div>
Computes length of this vector.
Computes the length of this vector.
</div>
<h3>[method:Float lengthManhattan]() [page:Vector4 this]</h3>
<div>
Computes the Manhattan length of this vector.<br />
[link:http://en.wikipedia.org/wiki/Taxicab_geometry]
</div>
<h3>[method:Vector4 normalize]() [page:Vector4 this]</h3>
......@@ -294,12 +300,6 @@
Index 3: w<br/>
</div>
<h3>[method:Float lengthManhattan]() [page:Vector4 this]</h3>
<div>
Computes Manhattan length of this vector.<br />
[link:http://en.wikipedia.org/wiki/Taxicab_geometry]
</div>
<h3>[method:Vector4 clone]() [page:Vector4 this]</h3>
<div>
Clones this vector.
......
......@@ -393,6 +393,12 @@ THREE.Vector2.prototype = {
},
distanceToManhattan: function ( v ) {
return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );
},
setLength: function ( length ) {
return this.multiplyScalar( length / this.length() );
......
......@@ -659,6 +659,12 @@ THREE.Vector3.prototype = {
},
distanceToManhattan: function ( v ) {
return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
},
setFromSpherical: function( s ) {
var sinPhiRadius = Math.sin( s.phi ) * s.radius;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册