mirror of
				https://github.com/hannobraun/Fornjot
				synced 2025-10-31 04:08:17 +00:00 
			
		
		
		
	Add Vector<3>::cross
				
					
				
			This commit is contained in:
		
							parent
							
								
									828326441e
								
							
						
					
					
						commit
						9152c23b92
					
				| @ -9,6 +9,22 @@ pub struct Vector<const D: usize> { | |||||||
|     pub components: [Scalar; D], |     pub components: [Scalar; D], | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl Vector<3> { | ||||||
|  |     #[allow(unused)] // code to use it is being worked on
 | ||||||
|  |     pub fn cross(self, other: Self) -> Self { | ||||||
|  |         let [ax, ay, az] = self.components; | ||||||
|  |         let [bx, by, bz] = other.components; | ||||||
|  | 
 | ||||||
|  |         Self { | ||||||
|  |             components: [ | ||||||
|  |                 ay * bz - az * by, | ||||||
|  |                 az * bx - ax * bz, | ||||||
|  |                 ax * by - ay * bx, | ||||||
|  |             ], | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| impl<S, const D: usize> From<[S; D]> for Vector<D> | impl<S, const D: usize> From<[S; D]> for Vector<D> | ||||||
| where | where | ||||||
|     S: Into<Scalar>, |     S: Into<Scalar>, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user