KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > physics > relativity > LorentzBoost


1 package JSci.physics.relativity;
2
3 import JSci.maths.vectors.Double3Vector;
4
5 /**
6 * The LorentzBoost class encapsulates the Lorentz boosts.
7 * @version 1.0
8 * @author Mark Hale
9 */

10 public final class LorentzBoost extends Rank2Tensor {
11         /**
12         * Constructs a Lorentz boost.
13         * @param v velocity
14         */

15         public LorentzBoost(Double3Vector v) {
16                 this(v.getComponent(0),v.getComponent(1),v.getComponent(2));
17         }
18         /**
19         * Constructs a Lorentz boost.
20         * @param vx x-velocity
21         * @param vy y-velocity
22         * @param vz z-velocity
23         */

24         public LorentzBoost(double vx,double vy,double vz) {
25                 final double vv=vx*vx+vy*vy+vz*vz;
26                 final double gamma=1.0/Math.sqrt(1.0-vv);
27                 final double k=(gamma-1.0)/vv;
28                 rank2[0][0]=gamma;
29                 rank2[0][1]=rank2[1][0]=-gamma*vx;
30                 rank2[0][2]=rank2[2][0]=-gamma*vy;
31                 rank2[0][3]=rank2[3][0]=-gamma*vz;
32                 rank2[1][1]=1.0+k*vx*vx;
33                 rank2[1][2]=rank2[2][1]=k*vx*vy;
34                 rank2[1][3]=rank2[3][1]=k*vx*vz;
35                 rank2[2][2]=1.0+k*vy*vy;
36                 rank2[2][3]=rank2[3][2]=k*vy*vz;
37                 rank2[3][3]=1.0+k*vz*vz;
38         }
39 }
40
41
Popular Tags