-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForce.java
More file actions
44 lines (41 loc) · 995 Bytes
/
Force.java
File metadata and controls
44 lines (41 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Class representing force vectors
*
* @author Austin
* @version 0
*/
public class Force extends Vector {
/**
* Constructor for Force with starting values
*
* @param x The x component of force
* @param y The y component of force
*/
public Force(double x, double y) {
super(x, y);
}
/**
* Constructor for a 0 Force
*/
public Force() {
super(0, 0);
}
/**
* Gets the acceleration of a mass when acted upon by the force
*
* @param mass The mass of the object
* @return The acceleration
*/
public Acceleration getAcceleration(double mass) {
return new Acceleration(x / mass, y / mass);
}
/**
* Add two Forces. Can be chained
*
* @param other Another force
* @return The resultant force
*/
public Force add(Force other) {
return new Force(x + other.getX(), y + other.getY());
}
}