mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	vector math: add implementation of Length and Normalize
This commit is contained in:
		
							parent
							
								
									55f5d0f777
								
							
						
					
					
						commit
						2e6d8e1321
					
				
					 1 changed files with 19 additions and 0 deletions
				
			
		|  | @ -186,6 +186,18 @@ Vec2<T> operator*(const V& f, const Vec2<T>& vec) { | |||
| 
 | ||||
| typedef Vec2<float> Vec2f; | ||||
| 
 | ||||
| template <> | ||||
| inline float Vec2<float>::Length() const { | ||||
|     return std::sqrt(x * x + y * y); | ||||
| } | ||||
| 
 | ||||
| template <> | ||||
| inline float Vec2<float>::Normalize() { | ||||
|     float length = Length(); | ||||
|     *this /= length; | ||||
|     return length; | ||||
| } | ||||
| 
 | ||||
| template <typename T> | ||||
| class Vec3 { | ||||
| public: | ||||
|  | @ -388,6 +400,13 @@ inline Vec3<float> Vec3<float>::Normalized() const { | |||
|     return *this / Length(); | ||||
| } | ||||
| 
 | ||||
| template <> | ||||
| inline float Vec3<float>::Normalize() { | ||||
|     float length = Length(); | ||||
|     *this /= length; | ||||
|     return length; | ||||
| } | ||||
| 
 | ||||
| typedef Vec3<float> Vec3f; | ||||
| 
 | ||||
| template <typename T> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue