Library reference

Tangent

Tangent is rise divided by horizontal run. Multiply it by the horizontal distance to find the rise. A 45-degree angle is about 0.7854 radians.

f64::tan

Simple example

Use an angle of zero radians.

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

Everyday examples

A model hill rises at 45 degrees over two horizontal metres. How high is it?

Start0.7853981633974483
Result1.9999999999999998
main.rs
fn main() {
    println!("{}", 2.0 * (0.7853981633974483_f64).tan());
}
Output
1.9999999999999998

A drawing shows a roof at 45 degrees across a three-metre horizontal run. What rise should be marked?

Start0.7853981633974483
Result2.9999999999999996
main.rs
fn main() {
    println!("{}", 3.0 * (0.7853981633974483_f64).tan());
}
Output
2.9999999999999996

A flat board runs five metres across the floor. How much does it rise?

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