-
-
Notifications
You must be signed in to change notification settings - Fork 514
Implemented Euler angles a separate crate #1500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TrifanBogdan24
wants to merge
2
commits into
dimforge:main
Choose a base branch
from
TrifanBogdan24:contribute-1446
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tdamsma
reviewed
Mar 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be included?
tdamsma
reviewed
Mar 30, 2025
Comment on lines
+151
to
+181
pub fn rotation_matrix_to_euler(rotation_matrix: &Vec<Vec<f64>>, order: &[char; 3]) -> Result<Vec<f64>, String> { | ||
// Validate the order | ||
for chr in order { | ||
if !matches!(*chr, 'X' | 'Y' | 'Z') { | ||
let err_msg = format!("Invalid order character '{}'. Expected X/Y/Z", chr); | ||
return Err(err_msg); | ||
} | ||
} | ||
|
||
let beta = -rotation_matrix[2][0].asin(); // Y-axis rotation (beta) | ||
let alpha = (rotation_matrix[2][1] / beta.cos()).atan2(rotation_matrix[2][2] / beta.cos()); // X-axis rotation (alpha) | ||
let gamma = (rotation_matrix[1][0] / beta.cos()).atan2(rotation_matrix[0][0] / beta.cos()); // Z-axis rotation (gamma) | ||
|
||
// Create a map to associate axes with their corresponding Euler angle functions | ||
let mut euler_map: HashMap<char, f64> = HashMap::new(); | ||
|
||
euler_map.insert('X', alpha); | ||
euler_map.insert('Y', beta); | ||
euler_map.insert('Z', gamma); | ||
|
||
let mut euler_angles = Vec::new(); | ||
|
||
for &axis in order { | ||
match euler_map.get(&axis) { | ||
Some(&angle) => euler_angles.push(angle), | ||
None => return Err(format!("Unexpected axis '{}'", axis)), | ||
} | ||
} | ||
|
||
Ok(euler_angles) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the using the extrinsic or extrinsic definition? And how to discern between those?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solved issue: #1446.
I implemented the algorithm behind calculus of Euler Angles as a nalgebra crate.
I also provided a brief README of how to use these simple, yet powerful functions.