-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKinematicWander.cpp
More file actions
28 lines (23 loc) · 817 Bytes
/
KinematicWander.cpp
File metadata and controls
28 lines (23 loc) · 817 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
#include <cmath>
#include <vector>
#include "KinematicWander.hpp"
#include "Ent.hpp"
#include "Triple.hpp"
#include "util.hpp"
KinematicWander::KinematicWander(std::string name, Ent *character, double maxSpeed, double maxRotation, double wanderTime):
DirectKinematicV(name),
character(character),
maxSpeed(maxSpeed),
maxRotation(maxRotation),
wanderTime(wanderTime),
accum(0)
{}
std::vector<Triple> KinematicWander::getVel(unsigned int ticks, unsigned int delta_ticks) {
Triple steering;
double ang;
if (this->accum == 0) {
ang = RandBin(-1,1) * maxRotation;
}
if ((this->accum += delta_ticks) >= wanderTime) this->accum = 0;
return std::vector<Triple>(1, Triple(cos(ang), sin(ang), 0) * maxSpeed);
}