浏览代码

Merge branch 'dev' of https://github.com/mrdoob/three.js into dev

Mr.doob 10 年之前
父节点
当前提交
2e53761eca
共有 2 个文件被更改,包括 11 次插入0 次删除
  1. 6 0
      docs/api/math/Vector2.html
  2. 5 0
      src/math/Vector2.js

+ 6 - 0
docs/api/math/Vector2.html

@@ -103,6 +103,12 @@
 		Computes length of this vector.
 		</div>
 
+		<h3>[method:Float lengthManhattan]()</h3>
+		<div>
+		Computes Manhattan length of this vector.<br />
+		[link:http://en.wikipedia.org/wiki/Taxicab_geometry]
+		</div>
+
 		<h3>[method:Vector2 normalize]() [page:Vector2 this]</h3>
 		<div>
 		Normalizes this vector.

+ 5 - 0
src/math/Vector2.js

@@ -337,6 +337,11 @@ THREE.Vector2.prototype = {
 
 	},
 
+	lengthManhattan: function() {
+
+		return Math.abs( this.x ) + Math.abs( this.y );
+	},
+
 	normalize: function () {
 
 		return this.divideScalar( this.length() );