mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Tweak to euler angles euristic
This commit is contained in:
		
							parent
							
								
									348aa48121
								
							
						
					
					
						commit
						9d51348272
					
				
					 1 changed files with 8 additions and 6 deletions
				
			
		|  | @ -1194,15 +1194,12 @@ Vec3d extract_euler_angles(const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>& | ||||||
|         { |         { | ||||||
|             angles1(1) = 0.5 * (double)PI; |             angles1(1) = 0.5 * (double)PI; | ||||||
|             angles1(2) = angles1(0) + ::atan2(rotation_matrix(0, 1), rotation_matrix(0, 2)); |             angles1(2) = angles1(0) + ::atan2(rotation_matrix(0, 1), rotation_matrix(0, 2)); | ||||||
| 
 |  | ||||||
|         } |         } | ||||||
|         else // == -1.0
 |         else // == -1.0
 | ||||||
|         { |         { | ||||||
|             angles1(1) = 0.5 * (double)PI; |             angles1(1) = 0.5 * (double)PI; | ||||||
|             angles1(2) = -angles1(0) - ::atan2(rotation_matrix(0, 1), rotation_matrix(0, 2)); |             angles1(2) = -angles1(0) - ::atan2(rotation_matrix(0, 1), rotation_matrix(0, 2)); | ||||||
| 
 |  | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|         angles2 = angles1; |         angles2 = angles1; | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|  | @ -1218,9 +1215,14 @@ Vec3d extract_euler_angles(const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>& | ||||||
|         angles2(2) = ::atan2(rotation_matrix(1, 0) * inv_cos2, rotation_matrix(0, 0) * inv_cos2); |         angles2(2) = ::atan2(rotation_matrix(1, 0) * inv_cos2, rotation_matrix(0, 0) * inv_cos2); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // The following euristic seems to work fine, but there may be use cases were it does not
 |     // The following euristic is the best found up to now (in the sense that it works fine with the greatest number of edge use-cases)
 | ||||||
|     // We'll need to modify it if/when we'll meet such use cases
 |     // but there are other use-cases were it does not
 | ||||||
|     Vec3d angles = (angles1.cwiseAbs().minCoeff() <= angles2.cwiseAbs().minCoeff()) ? angles1 : angles2; |     // We need to imrove it
 | ||||||
|  |     double min_1 = angles1.cwiseAbs().minCoeff(); | ||||||
|  |     double min_2 = angles2.cwiseAbs().minCoeff(); | ||||||
|  |     bool use_1 = (min_1 < min_2) || (is_approx(min_1, min_2) && (angles1.norm() <= angles2.norm())); | ||||||
|  | 
 | ||||||
|  |     Vec3d angles = use_1 ? angles1 : angles2; | ||||||
| #else | #else | ||||||
|     auto y_only = [](const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>& matrix) -> bool { |     auto y_only = [](const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>& matrix) -> bool { | ||||||
|         return (matrix(0, 1) == 0.0) && (matrix(1, 0) == 0.0) && (matrix(1, 1) == 1.0) && (matrix(1, 2) == 0.0) && (matrix(2, 1) == 0.0); |         return (matrix(0, 1) == 0.0) && (matrix(1, 0) == 0.0) && (matrix(1, 1) == 1.0) && (matrix(1, 2) == 0.0) && (matrix(2, 1) == 0.0); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Enrico Turri
						Enrico Turri