-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObject.h
56 lines (42 loc) · 1.27 KB
/
Object.h
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
#ifndef GravitySim_object_h
#define GravitySim_object_h
#include <stdbool.h>
#include "basic_types.h"
class Object {
private:
public:
Point2D position;
Point2D speed;
GS_FLOAT mass;
Object(Point2D position, Point2D speed, GS_FLOAT mass);
Object();
/**
* make an object with the specified position, speed and mass
*/
static Object make(Point2D position, Point2D speed, GS_FLOAT mass);
/**
* randomly make an object with specified bounds, max_speed and max_mass
*/
static Object make_random(RectangleD bounds, GS_FLOAT max_speed, GS_FLOAT max_mass);
/**
* randomly make an obejct with specified bounds, max_speed and max_mass in an ellipse
*/
static Object make_random_in_ellipse(RectangleD bounds, GS_FLOAT max_speed, GS_FLOAT max_mass);
/**
* object with zero position and mass
*/
static Object make_zero();
/**
* calculating the sum of two objects, weighted by mass, return the new object
*/
static Object add(Object a, Object b);
/**
* calculate the force between object a and b
*/
static Point2D calculate_force(Object a, Object b);
/**
* object's position update with a specified dt
*/
void update_position(GS_FLOAT dt);
};
#endif