Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 965 Bytes

File metadata and controls

51 lines (38 loc) · 965 Bytes

How to use nalgebra's Euler Angles in your code

Rotation on OX axis

let rotation_matrix = rotation_x(&45.0);
println!("{:?}", rotation_matrix);

Rotation on OY axis

let rotation_matrix = rotation_y(&45.0);
println!("{:?}", rotation_matrix);

Rotation on OZ axis

let rotation_matrix = rotation_z(&45.0);
println!("{:?}", rotation_matrix);

Euler to rotation matrix

let angles = [45.0, 30.0, 60.0];
let order = ['X', 'Y', 'Z'];
match euler_to_rotation_matrix(&angles, &order) {
    Ok(matrix) => println!("{:?}", matrix),
    Err(err) => println!("Error: {}", err),
}

Rotation matrix to euler

let rotation_matrix = vec![
    vec![0.5, -0.5, 0.7071],
    vec![0.7071, 0.7071, 0.0],
    vec![-0.5, -0.5, 0.7071]
];
let order = ['X', 'Y', 'Z'];
match rotation_matrix_to_euler(&rotation_matrix, &order) {
    Ok(angles) => println!("{:?}", angles),
    Err(err) => println!("Error: {}", err),
}