- add javadoc for Vector3f.project
- add Vector3f.projectLocal git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10359 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
b5ef1e39e7
commit
463a532025
@ -383,12 +383,31 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Projects this vector onto another vector
|
||||||
|
*
|
||||||
|
* @param other The vector to project this vector onto
|
||||||
|
* @return A new vector with the projection result
|
||||||
|
*/
|
||||||
public Vector3f project(Vector3f other){
|
public Vector3f project(Vector3f other){
|
||||||
float n = this.dot(other); // A . B
|
float n = this.dot(other); // A . B
|
||||||
float d = other.lengthSquared(); // |B|^2
|
float d = other.lengthSquared(); // |B|^2
|
||||||
return new Vector3f(other).normalizeLocal().multLocal(n/d);
|
return new Vector3f(other).normalizeLocal().multLocal(n/d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Projects this vector onto another vector, stores the result in this
|
||||||
|
* vector
|
||||||
|
*
|
||||||
|
* @param other The vector to project this vector onto
|
||||||
|
* @return This Vector3f, set to the projection result
|
||||||
|
*/
|
||||||
|
public Vector3f projectLocal(Vector3f other){
|
||||||
|
float n = this.dot(other); // A . B
|
||||||
|
float d = other.lengthSquared(); // |B|^2
|
||||||
|
return set(other).normalizeLocal().multLocal(n/d);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this vector is a unit vector (length() ~= 1),
|
* Returns true if this vector is a unit vector (length() ~= 1),
|
||||||
* returns false otherwise.
|
* returns false otherwise.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user