## Coordinate systems

Coordinate systems and especially transformations between local and world coordinates are used in robotics very often. Here is a small but practical introduction into the topic.

There are different types of coordinate systems but when we talk about robotic the most popular are:

1. The standard Cartesian coordinates - values x, y specify position of a point as a distance from the coordinate system origin. Origin is the point where coordinate system axis cross each other. These axis are perpendicular. Computer display uses this type of coordinate system.
2. The standard Polar coordinates - 2D coordinate system in which position of a point in a plane is determined by a distance from a fixed point (r) and an angle (theta) from a fixed direction.
When we want to transform local to world coordinates and vise verse we need to do that in a specific coordinate system. Let's focus on Cartesian coordinate system. In the system we use matrices and vectors to do the job.

Transformation matrix - the coordinate system that is rotating while the object remains fixed.  (http://www.continuummechanics.org/cm/coordxforms.html)
Q = [cos(theta), sin(theta); -sin(theta), cos(theta)] = R'
$Q^{-1}$ = $Q'$ = $R$
Let $v_{new}$ and $v_{old}$ be vectors than
$v_{new} = Q * v_{old}$

Rotation matrix - the object rotates while the coordinate system remains fixed.
R = [cos(theta), -sin(theta); sin(theta), cos(theta)] = Q'
$R^{-1}$ = $R'$ = $Q$
Let $v_{new}$ and $v_{old}$ be vectors than
$v_{new} = R * v_{old}$

Transformation from global to local coordinates and vise versa in Octave/Matlab

clear all;
close all;
clc;

offset = 0.1;

%Transformation matrix from global to local coordinates
theta1 = -pi/4;
x1 = 2;
y1 = 2;
R1 = [cos(theta1), - sin(theta1), x1; sin(theta1), cos(theta1), y1; 0, 0, 1];

%Transformation matrix from local to global coordinates
R1_inv = inv(R1);

%Points in global and local coordinate system
Xg = [1;2;1];
Xl = [1;1;1];
%Temp vector used to store temporary math result
TMP = [0;0;0];

%Vector containing data to be plotted - initially filled by min and max values so the plot has dimensions 0 - 10 in x direction and 0 - 10 in y direction
x=[0,0;10,0];
y=[0,0;10,0];

%Display Xg in global CS
printf("Xg in global CS - no transformation needed: ");
TMP = Xg
text (TMP(1,1) + offset,TMP(2,1) - offset, "Xg in\ngl. CS");
hold on
x=[x;TMP(1),0]; %Add result into vector that will be plotted
y=[y;TMP(2),0]; %Add result into vector that will be plotted

%Display Xl in global CS
printf("Xl in global CS - transformed via R1: ");
TMP = R1*Xl
text (TMP(1,1) + offset,TMP(2,1) - offset, "Xl in\ngl. CS");
hold on
x=[x;TMP(1),0];
y=[y;TMP(2),0];

%Display Xg in local CS
printf("Xg in local CS - transformed via R1_inv: ");
TMP = R1_inv*Xg
text (TMP(1,1) + offset,TMP(2,1) - offset, "Xg in local CS\nnote: [0,0] of this view is taken as origin of the local CS for this point");
hold on
x=[x;TMP(1),0];
y=[y;TMP(2),0];

%Plot
stem(x,y);

%Save
print("local_to_global_coords_transforms.png");

----------------------------------------------------------------------

Source code : local_to_global_coords_transforms.m

Extended source code : local_to_global_coords_transforms_ext.m

I read this paragraph fully concerning the resemblance of most
recent and preceding technologies, it's awesome article.

0 #19 8 2019-04-17 04:52
I don't know if it's just me or if perhaps everybody else encountering problems with your site.

It seems like some of the text on your content are running off the screen. Can someone else please provide
feedback and let me know if this is happening to them too?
This could be a problem with my browser because I've had this happen before.

Many thanks

My web page 8: https://showbizplus.com/index.php/blog/885979/awesome-hd-net-ww1/

We are a bunch of volunteers and starting a brand new scheme in our community.
Your website provided us with helpful information to work on. You've done an impressive job
and our whole neighborhood will likely be thankful to you.

Howdy! This is kind of off topic but I need some advice from an established blog.
Is it hard to set up your own blog? I'm not
very techincal but I can figure things out pretty
fast. I'm thinking about making my own but I'm
not sure where to start. Do you have any ideas or suggestions?
Thanks

Hello! I realize this is somewhat off-topic
but I needed to ask. Does managing a well-established website like yours take a massive amount work?
I'm brand new to running a blog but I do write in my journal daily.
I'd like to start a blog so I can share my personal experience and views online.

Please let me know if you have any kind of suggestions or tips for new aspiring blog owners.
Thankyou!

0 #15 3 2019-03-05 20:37
I couldn't resist commenting. Exceptionally well written!

Also visit my web-site; 3: https://training.work4a1.com/groups/sims-2-super-collection-mac-%e2%80%8ethe-sims-2-super-collection-on-the-mac-app/

0 #14 RheaBig 2019-02-27 10:20
Hello. I have checked your concordia.sk and i see you've got some duplicate content so probably it is the reason that you don't rank hi
in google. But you can fix this issue fast. There is a tool that rewrites articles like human, just search in google: miftolo's tools

0 #13 9 2019-02-25 15:12
Do you have a spam problem on this site; I also am a blogger, and
I was wondering your situation; we have developed some nice practices
and we are looking to exchange methods with other folks, please shoot me an e-mail if
interested.

my web page: 9: http://gardenpjw.dothome.co.kr/board_LOcC77/1745

Pretty section of content. I just stumbled upon your website and in accession capital to assert that I acquire in fact enjoyed account your blog posts.
Anyway I'll be subscribing to your feeds and even I achievement you access consistently rapidly.

0 #11 viagra tablets 2019-01-21 09:28
It's appropriate time to make some plans for the future and
it is time to be happy. I've read this post and if I could I wish to suggest you
some interesting things or advice. Perhaps you could write next articles