-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrigid_object.cpp
More file actions
88 lines (74 loc) · 1.49 KB
/
rigid_object.cpp
File metadata and controls
88 lines (74 loc) · 1.49 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
#include "rigid_object.h"
#include "geo_util.h"
Object::Object() :
v(0, 0),
omega(0),
m(8000000),
i(20000000),
elasticity(0.2),
f_k(0.2f),
f_s_max(0.5f),
bound_box(0, 0, 0, 0),
cog(0, 0),
theta(0) {}
Object::Object(Vec in_cog, float in_theta, float in_mass) :
v(0, 0),
omega(0),
m(in_mass),
i(20000000),
elasticity(0.2),
f_k(0.2f),
f_s_max(0.5f),
bound_box(0, 0, 0, 0),
cog(in_cog),
theta(in_theta) {}
const Vec& Object::getCog() const
{
return cog;
}
const float& Object::getTheta() const
{
return theta;
}
Object::Category Object::category() const
{
return Category::Base;
}
void Object::setCog(const Vec& c)
{
cog = c;
}
void Object::setTheta(const float& t)
{
theta = t;
}
void Object::translate(const Vec& disp)
{
cog = cog + disp;
}
void Object::update(float t)
{
cog += v * t;
theta += omega * t;
}
Vec Object::closestPoint(const Vec& pt) const
{
return cog;
}
Vec Object::furthestPoint(const Vec& dir) const
{
return cog;
}
Segment Object::projectOnto(const Vec& axis) const
{
return {projectPoint(cog, axis), projectPoint(cog, axis)};
}
bool Object::intersectedBy(Object& o, Collision& c)
{
return false;
}
bool Object::checkIntersect(Object& o, Collision& c)
{
// Guaranteed to evaluate the left condition first.
return (intersectedBy(o, c) && o.intersectedBy(*this, c));
}