Library reference

Inverse tangent

Find the angle of a slope from rise divided by horizontal run. The result is in radians.

f64::atan

Simple example

Find the angle for this ratio.

Start0
Result0
main.rs
fn main() {
    println!("{}", (0.0_f64).atan());
}
Output
0
Advertisements

Everyday examples

A model road rises one metre for each horizontal metre. What is its angle?

Start1
Result0.7853981633974483
main.rs
fn main() {
    println!("{}", (1.0_f64).atan());
}
Output
0.7853981633974483

A drawing shows a rise of one metre for every two across. What angle should be marked?

Start0.5
Result0.46364760900080615
main.rs
fn main() {
    println!("{}", (0.5_f64).atan());
}
Output
0.46364760900080615

A flat path has zero rise per metre. What is its angle?

Start0
Result0
main.rs
fn main() {
    println!("{}", (0.0_f64).atan());
}
Output
0
Run the example
Terminal
rustc main.rs
./main
Official documentation