Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update src/core/Vector3.js

Would be great if the function to get angle to anonther vector could be implemented in this Vector3 class.
Hope you guys like the idea.
  • Loading branch information...
commit 385b4728852e99ed93972b54dbf5af8c47447813 1 parent ef5f05d
@Wilt authored
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/core/Vector3.js
View
6 src/core/Vector3.js
@@ -249,6 +249,12 @@ THREE.Vector3.prototype = {
},
+ angleTo: function ( v ) {
+ //angle between this and v:
+ //this 'dot' v = |this|*|v|*cos(alpha), where alpha is the angle
+ return Math.acos( (this.x*v.x+this.y*v.y+this.z*v.z) / (Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2)+Math.pow(this.z,2))) / (Math.sqrt(Math.pow(v.x,2)+Math.pow(v.y,2)+Math.pow(v.z,2))) );
+ };
+
distanceTo: function ( v ) {
return Math.sqrt( this.distanceToSquared( v ) );
Please sign in to comment.
Something went wrong with that request. Please try again.