Add cross product operation to Vector3
This commit is contained in:
		
							parent
							
								
									a41817217a
								
							
						
					
					
						commit
						5d14a63c37
					
				
					 2 changed files with 14 additions and 0 deletions
				
			
		|  | @ -205,6 +205,19 @@ Vector3::dot(const Vector3 &v) | |||
| } | ||||
| 
 | ||||
| 
 | ||||
| /*
 | ||||
|  * Vector3::cross -- | ||||
|  * | ||||
|  * Compute and return the cross product of this and the given vectors. | ||||
|  */ | ||||
| Vector3 | ||||
| Vector3::cross(const Vector3 &v) | ||||
|     const | ||||
| { | ||||
|     return Vector3(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /*
 | ||||
|  * Vector3::normalize -- | ||||
|  * | ||||
|  |  | |||
|  | @ -34,6 +34,7 @@ struct Vector3 | |||
|     float length2() const; | ||||
|     float length() const; | ||||
|     float dot(const Vector3 &v) const; | ||||
|     Vector3 cross(const Vector3 &v) const; | ||||
| 
 | ||||
|     Vector3 &normalize(); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue