# How to calculate quaterion for 2d navigation between 2 points

So I was doing 2d navigation and I am basically doing using this code: http://wiki.ros.org/navigation/Tutori...

In there it has:

goal.target_pose.pose.position.x = 1;

goal.target_pose.pose.orientation.w = 1;

and this is suppose to make it go straight. I am guess it is at (0,0) and it is going to (1,0). So I am wondering how I can calculate quaternion between 2 points if I want it to go to a point. And if that's the concept. Because as I see it, the line orientation is rotating at a certain angle to be able to go to the given point (x,y). So it's rotate at orientation.w then go straight to (position.x, position.y). If that's not it it's work please tell me if it is also please tell me.

Also I did a little digging and found this:

```
float x[3] = {1.228,2.57,0.014};
float y[3] = {-3.34,-0.97,-0.97};
float w[3] = {-0.48,0.33,-2.58};
goal.target_pose.pose.position.x = x[i];
goal.target_pose.pose.position.y = y[i];
goal.target_pose.pose.orientation.w = w[i];
```

It is sending goal to 3 points and it keeps going. But I don't know how they calculate the w[3] array.

Also I found this:

```
double radians = theta * (M_PI/180);
tf::Quaternion quaternion;
quaternion = tf::createQuaternionFromYaw(radians);
geometry_msgs::Quaternion qMsg;
tf::quaternionTFToMsg(quaternion, qMsg);
goal.target_pose.pose.orientation = qMsg;
```

and I am wondering if it is right and if it is elaborate a little bit on it.

Any help is appreciated! Thank you!