KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > physics > AbstractClassicalParticle


1 package JSci.physics;
2
3 import JSci.maths.vectors.AbstractDoubleVector;
4
5 public abstract class AbstractClassicalParticle extends Particle {
6     /**
7      * @jsci.planetphysics mass
8      */

9         public abstract double getMass();
10         public abstract AbstractDoubleVector getPosition();
11     /**
12      * @jsci.planetphysics velocity
13      */

14         public abstract AbstractDoubleVector getVelocity();
15     /**
16      * @jsci.planetphysics momentum
17      */

18         public AbstractDoubleVector getMomentum() {
19                 return getVelocity().scalarMultiply(getMass());
20         }
21         public double speed() {
22                 return getVelocity().norm();
23         }
24         public double energy() {
25                 AbstractDoubleVector vel = getVelocity();
26                 return getMass()*vel.scalarProduct(vel)/2.0;
27         }
28 }
29
30
Popular Tags