Skip to content

TheMehranKhan/relativist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Relativist - Special Relativity Calculator

A simple Java library for calculating relativistic effects from Einstein's special relativity.

Formulas

Lorentz Factor

$$\gamma = \frac{1}{\sqrt{1 - \frac{v^2}{c^2}}}$$

where:

  • $v$ is the relative velocity
  • $c \approx 3 \times 10^8$ m/s is the speed of light

Time Dilation

$$t' = \gamma t$$

  • $t$ = proper time (time in rest frame)
  • $t'$ = dilated time (time in moving frame)

Length Contraction

$$L' = \frac{L}{\gamma}$$

  • $L$ = proper length (length in rest frame)
  • $L'$ = contracted length (length in moving frame)

Mass-Energy Equivalence

$$E = mc^2$$

Usage

double v = 0.8 * Relativist.C; // 80% speed of light
double properTime = 10.0; // years

double dilatedTime = Relativist.timeDilation(properTime, v);
double gamma = Relativist.gamma(v);
double energy = Relativist.energyMass(1.0); // 1 kg

// New features
double relativisticMass = Relativist.relativisticMass(1.0, v);
double combinedVelocity = Relativist.velocityAddition(0.5 * C, 0.5 * C);
double[] transformed = Relativist.lorentzTransform(t, x, v);
double doppler = Relativist.dopplerFactor(v, 0);

API

Method Description
gamma(v) Lorentz factor
timeDilation(t, v) Dilated time from proper time
properTime(t, v) Proper time from dilated time
lengthContraction(L, v) Contracted length from proper length
properLength(L, v) Proper length from contracted length
energyMass(m) E = mc²
massEnergy(E) m = E/c²
relativisticMass(m, v) Relativistic mass
velocityAddition(v1, v2) Relativistic velocity addition
lorentzTransform(t, x, v) Lorentz transformation
dopplerFactor(v, angle) Relativistic Doppler factor
relativisticMomentum(m, v) Relativistic momentum
kineticEnergy(m, v) Relativistic kinetic energy

Run

cd relativist
javac src/Relativist.java -d out
java -cp out Relativist

License

MIT

About

Java library for calculating relativistic effects: time dilation, length contraction, mass-energy equivalence

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages