KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > physics > RelativisticParticle


1 package JSci.physics;
2
3 import JSci.GlobalSettings;
4 import JSci.physics.relativity.*;
5
6 /**
7 * The RelativisticParticle class provides an object for
8 * encapsulating relativistic particles.
9 * @version 1.0
10 * @author Mark Hale
11 */

12 public abstract class RelativisticParticle extends Particle {
13         /**
14         * Constructs a relativistic particle.
15         */

16         public RelativisticParticle() {}
17         /**
18         * Rest mass.
19         */

20         public abstract double restMass();
21         /**
22         * Position 4-vector.
23         */

24         public Rank1Tensor position=new Rank1Tensor(0.0,0.0,0.0,0.0);
25         /**
26         * Momentum 4-vector.
27         */

28         public Rank1Tensor momentum=new Rank1Tensor(0.0,0.0,0.0,0.0);
29         /**
30         * Compares two particles for equality.
31         * @param p a relativistic particle
32         */

33         public boolean equals(Object JavaDoc p) {
34                 return (p!=null) && (p instanceof RelativisticParticle) &&
35                         (position.equals(((RelativisticParticle)p).position)) &&
36                         (momentum.equals(((RelativisticParticle)p).momentum)) &&
37                         (Math.abs(restMass()-((RelativisticParticle)p).restMass())<=GlobalSettings.ZERO_TOL);
38         }
39         public int hashCode() {
40             return (int) restMass();
41         }
42 }
43
44
Popular Tags