-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathodeSolver.cpp
65 lines (45 loc) · 1.47 KB
/
odeSolver.cpp
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
#include "odeSolver.h"
odeSolver::odeSolver(body* myBody, float timeStep, uint time)
:
timeStep_(timeStep),
simTime_(time),
body_(myBody),
solution_(timeStep_* time, 18, 0)
{
}
void odeSolver::solve()
{
float time = 0.0;
while(time < simTime_)
{
// DID: These below lines demand copy constructor. I haven't write one.
//
// TODO: Can't directly access body -> kinematics_. Then I need to write getter which returns by value.
// This demands copy constructor of kinematic class.
tensor<float> moi = body_ -> MoI_;
float mass = body_ -> mass_;
tensor<float> pqr = body_ -> kinematics_.getPqr();
tensor<float> uvw = body_ -> kinematics_.getUvw();
tensor<float> mapper = body_ -> kinematics_.getMapper();
tensor<float> gravity = body_ -> dynamics_.getGravity();
tensor<float> force = body_ -> dynamics_.getForce();
tensor<float> moment = body_ -> dynamics_.getMoment();
tensor<float>* Adress_pqr = &pqr;
tensor<float>* Adress_uvw = &uvw;
tensor<float>* Adress_eulers = &eulers;
tensor<float>* Adress_mapper = &mapper;
tensor<float>* Adress_gravity = &gravity;
tensor<float>uvwDot = (force + moment) / mass + (mapper * gravity) - (pqr % uvw);
//tensor<float>pqrDot = ~moi * (moment - pqr % (moi * pqr));
std::cout << "uvwDot" << std::endl;
uvwDot.print();
/*
std::cout << "pqrDot" << std::endl;
pqrDot.print();
*/
time += simTime_;
}
}
void odeSolver::setInitials(body* target)
{
}