Skip to main content
  1. Projects/

special-relativity-time-dilation

·80 words·1 min
Jake Roggenbuck
Author
Jake Roggenbuck
I am currently studying Computer Science

special-relativity-time-dilation #

Rust
Rust

Calculate the time dilation by velocity as described by special relativity using Rust! 🦀

Code #

fn time_dilation_by_velocity(t: f64, v: f64) -> f64 {
    t / (1.0 - ((v * v) / (C * C))).sqrt()
}

Units Used #

t: time in seconds
v: km/s

Constants #

const C: f64 = 299_792_458.0;

Equation #

Here is the equation for time dilation from velocity.

image

See Also #

I also wrote this code in my language called Component seen below:

image