-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBody.java
More file actions
89 lines (74 loc) · 2.51 KB
/
Body.java
File metadata and controls
89 lines (74 loc) · 2.51 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Interface for representating two dimensional circular bodies for
* physics simulations
* @author Sean Stern
* @version 1.0
*/
public interface Body{
/**
* Gets the x-coordinate of the two dimensional body. This method is useful
* for visualizing the simluation.
*
* @return the x-coordinate of the two dimensional body.
*/
public double getXCoord();
/**
* Gets the y-coordinate of the two dimensional body. This method is useful
* for visualizing the simulation.
*
* @return the y-coordinate of the two dimensional body.
*/
public double getYCoord();
/**
* Gets the x component of the velocity of the dimensional body.
*
* @return the x component of the velocity of the two dimensional body.
*/
public double getXVel();
/**
* Gets the y component of the velocity of the two dimensional body.
*
* @return the y component of the velocity of the two dimensional body..
*/
public double getYVel();
/**
* Gets the radius of the two dimensional body. This method is useful for
* visualizing the simulation.
*
* @return the radius of the two dimensional body.
*/
public double getRadius();
/**
* Gets the color (red, green, and blue values on a 0-255 scale) of the
* body. This method is useful for visualizing the simulation.
*
* @return an array of length 3 representing the color of the body; the
* value at 0th index represents red on a 0-255 scale, the value
* at the 1st green on a 0-255 scale, and the value at 2nd blue
* on a 0-255 scale
*/
public int[] getRGB();
/**
* Gets the mass of two dimensional body.
*
* @return the mass of the two dimensional body.
*/
public double getMass();
/**
* Calculates the force exterted on this two dimensional body by another
* two dimensional body.
*
* @param otherBody the {@link TwoDimBody} exterting a force on this two
* two dimensional body
*/
public void addForceFrom(Body otherBody);
/**
* Based on the forces exterted on this two dimensional body and the
* existing position of the two dimensional body, determines the new
* position of the body after moving for the provided amount of time.
* Also should reset the forces on the {@link Body} to 0.
*
* @param timeDelta the amount of time the body moves
*/
public void move(double timeDelta);
}