-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpose.h
85 lines (73 loc) · 2.3 KB
/
pose.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
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
//========================================================================
// This software is free: you can redistribute it and/or modify
// it under the terms of the GNU General Public License Version 3,
// as published by the Free Software Foundation.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// Version 3 in the file COPYING that came with this distribution.
// If not, see <http://www.gnu.org/licenses/>.
//========================================================================
/*!
\file pose.h
\brief Pose Class Definitions
\author James R. Bruce <[email protected]>, (C) 2007
*/
//========================================================================
#ifndef _INCLUDED_POSE_H_
#define _INCLUDED_POSE_H_
#define POSE_TEM \
template <class vector,class real>
#define POSE_FUN \
DynamicPose2D<vector,real>
#include <stdio.h>
//==== Pose Class Definition =========================================//
/*!
\class DynamicPose2D
\brief A 2D Pose class
\author James R. Bruce <[email protected]>, (C) 2007
*/
POSE_TEM
class DynamicPose2D{
public:
// pose specified in world coordinates
vector loc;
vector vel;
real angle;
real ang_vel;
public:
vector heading; // unit vector
public:
void setup();
// methods for transforming a point
vector toLocal(const vector &wp) const
{return(heading.project_in(wp - loc));}
vector toWorld(const vector &lp) const
{return(loc + heading.project_out(lp));}
// methods for transforming a point and a velocity
void toLocal(vector &wp,vector &wv) const;
void toWorld(vector &lp,vector &lv) const;
};
//==== Pose Class Implementation =====================================//
POSE_TEM
void POSE_FUN::setup()
{
heading.heading(angle);
}
POSE_TEM
void POSE_FUN::toLocal(vector &wp,vector &wv) const
{
wp = heading.project_in(wp - loc);
wv = heading.project_in(wv - vel) - wp.perp()*ang_vel;
}
POSE_TEM
void POSE_FUN::toWorld(vector &lp,vector &lv) const
{
lv = vel + heading.project_out(lv + lp.perp()*ang_vel);
lp = loc + heading.project_out(lp);
}
#endif