-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpos_update.m
25 lines (23 loc) · 930 Bytes
/
pos_update.m
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
function [pos] = pos_update(origin, rot, pos_relative)
%POS_UPDATE converts a relative bot/sensor position to an absolute one
% This function converts a relative position vector to an absolute one
% based on an origin position and rotation value.
%
% The origin position (origin) should be a two element vector [x, y]
% containing the absolue positionof the origin.
%
% The rotation vector (rot) should be a scalar indicating the rotation
% angle in degrees.
%
% The relative position (pos_relative) should be a matrix with each row
% containing a set of coordinates [x, y].
%
% Copyright (c) 2020, Ian G. Bennett
% All rights reserved.
% Development funded by the University of Toronto, Department of
% Mechanical and Industrial Engineering.
% Distributed under GNU AGPLv3 license.
% Rotate vector
pos = rotation(pos_relative, rot);
pos = repmat(origin, size(pos_relative,1), 1) + pos;
end