KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > physics > ConstantForce3D


1 package JSci.physics;
2
3 /**
4 * The ConstantForce3D class provides an object for encapsulating constant forces in 3D.
5 * @version 1.0
6 * @author Mark Hale
7 * @author Silvere Martin-Michiellot
8 */

9 public class ConstantForce3D extends Force3D {
10         protected final double Fx, Fy, Fz;
11         /**
12         * Constructs a force.
13         */

14         public ConstantForce3D(double fx, double fy, double fz) {
15                 Fx = fx;
16                 Fy = fy;
17                 Fz = fz;
18         }
19         /**
20         * Returns the addition of this force and another.
21         */

22         public Force3D add(ConstantForce3D F) {
23                 return new ConstantForce3D(Fx+F.Fx, Fy+F.Fy, Fz+F.Fz);
24         }
25         /**
26         * Returns the subtraction of this force by another.
27         */

28         public Force3D subtract(ConstantForce3D F) {
29                 return new ConstantForce3D(Fx-F.Fx, Fy-F.Fy, Fz-F.Fz);
30         }
31         public double getXComponent(double t) {
32                 return Fx;
33         }
34         public double getYComponent(double t) {
35                 return Fy;
36         }
37         public double getZComponent(double t) {
38                 return Fz;
39         }
40 }
41
42
Popular Tags