A simple Java library for calculating relativistic effects from Einstein's special relativity.
where:
-
$v$ is the relative velocity -
$c \approx 3 \times 10^8$ m/s is the speed of light
-
$t$ = proper time (time in rest frame) -
$t'$ = dilated time (time in moving frame)
-
$L$ = proper length (length in rest frame) -
$L'$ = contracted length (length in moving frame)
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);| 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 |
cd relativist
javac src/Relativist.java -d out
java -cp out RelativistMIT