Browse Source

Vector3: Added .setFromCylindrical

Mugen87 8 years ago
parent
commit
013a35e80e
2 changed files with 16 additions and 1 deletions
  1. 5 0
      docs/api/math/Vector3.html
  2. 11 1
      src/math/Vector3.js

+ 5 - 0
docs/api/math/Vector3.html

@@ -202,6 +202,11 @@
 		Sets this vector from the spherical coordinates *s*.
 		</div>
 
+		<h3>[method:Vector3 setFromCylindrical]( [page:Cylindrical c] ) [page:Vector3 this]</h3>
+		<div>
+		Sets this vector from the cylindrical coordinates *c*.
+		</div>
+
 		<h3>[method:Vector3 clamp]( [page:Vector3 min], [page:Vector3 max] ) [page:Vector3 this]</h3>
 		<div>
 		min -- [page:Vector3] <br />

+ 11 - 1
src/math/Vector3.js

@@ -79,7 +79,7 @@ Vector3.prototype = {
 			default: throw new Error( 'index is out of range: ' + index );
 
 		}
-		
+
 		return this;
 
 	},
@@ -685,6 +685,16 @@ Vector3.prototype = {
 
 	},
 
+	setFromCylindrical: function( c ) {
+
+		this.x = c.radius * Math.sin( c.theta );
+		this.y = c.y;
+		this.z = c.radius * Math.cos( c.theta );
+
+		return this;
+
+	},
+
 	setFromMatrixPosition: function ( m ) {
 
 		return this.setFromMatrixColumn( m, 3 );