Added scaling to SphericalOf<T>
This commit is contained in:
		
							parent
							
								
									dedaa31740
								
							
						
					
					
						commit
						b460bec696
					
				| @ -192,6 +192,18 @@ SphericalOf<T> SphericalOf<T>::operator+=(const SphericalOf<T>& v) { | ||||
|   return *this; | ||||
| } | ||||
| 
 | ||||
| template <typename T> | ||||
| SphericalOf<T> SphericalOf<T>::operator*=(float f) { | ||||
|   this->distance *= f; | ||||
|   return *this; | ||||
| } | ||||
| 
 | ||||
| template <typename T> | ||||
| SphericalOf<T> SphericalOf<T>::operator/=(float f) { | ||||
|   this->distance /= f; | ||||
|   return *this; | ||||
| } | ||||
| 
 | ||||
| template class SphericalOf<float>; | ||||
| template class SphericalOf<signed short>; | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										27
									
								
								Spherical.h
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								Spherical.h
									
									
									
									
									
								
							| @ -65,6 +65,33 @@ class SphericalOf { | ||||
|   /// @return The result of the addition
 | ||||
|   SphericalOf<T> operator+(const SphericalOf<T>& v) const; | ||||
|   SphericalOf<T> operator+=(const SphericalOf<T>& v); | ||||
| 
 | ||||
|   /// @brief Scale the vector uniformly up
 | ||||
|   /// @param f The scaling factor
 | ||||
|   /// @return The scaled vector
 | ||||
|   /// @remark This operation will scale the distance of the vector. The angle
 | ||||
|   /// will be unaffected.
 | ||||
|   friend SphericalOf<T> operator*(const SphericalOf<T>& v, float f) { | ||||
|     return SphericalOf<T>(v.distance * f, v.horizontal, v.vertical); | ||||
|   } | ||||
|   friend SphericalOf<T> operator*(float f, const SphericalOf<T>& v) { | ||||
|     return SphericalOf<T>(v.distance * f, v.horizontal, | ||||
|                           v.vertical);  // not correct, should be f * v.distance
 | ||||
|   } | ||||
|   SphericalOf<T> operator*=(float f); | ||||
|   /// @brief Scale the vector uniformly down
 | ||||
|   /// @param f The scaling factor
 | ||||
|   /// @return The scaled factor
 | ||||
|   /// @remark This operation will scale the distance of the vector. The angle
 | ||||
|   /// will be unaffected.
 | ||||
|   friend SphericalOf<T> operator/(const SphericalOf<T>& v, float f) { | ||||
|     return SphericalOf<T>(v.distance / f, v.horizontal, v.vertical); | ||||
|   } | ||||
|   friend SphericalOf<T> operator/(float f, const SphericalOf<T>& v) { | ||||
|     return SphericalOf<T>(v.distance / f, v.horizontal, | ||||
|                           v.vertical);  // not correct, should be f / v.distance
 | ||||
|   } | ||||
|   SphericalOf<T> operator/=(float f); | ||||
| }; | ||||
| 
 | ||||
| using SphericalSingle = SphericalOf<float>; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user