Application of Rotation Matrix + Understanding ...

I am trying to apply the rotation matrix about the z-axis (altitude or north) correctly, and want to do a sanity check to make sure I understand it.

My goal at the end of this, is to take a local point (x, y, z) and transform it to "north local point" (a point with respect to north), call it (east, north, up).

I used the the rotation across z-axis "Rz" matrix from, where z appears to be altitude or north (axis out of the page).

Rotation matrix - Wikipedia, the free encyclopedia

Code:

theta = 0

%from wiki:

rotation_matrix_to_north = [cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0; 0 0 1]

%take a sample point on the earth, call it local point

xg = 1; yg = 1; zg = 1;

local_point = [xg; yg; zg]

%now transform that local point with respect to north via the rotation matrix

north_point = rotation_matrix_to_north * local_point

However, when I rotate with a theta of 180, my rotation_matrix_to_north equals

-1 0 0

0 -1 0

0 0 1

And my north_point after the rotation equals

-1

-1

1

My input or local_point =

1

1

1

I don't think this makes sense, since I would only expect the zg to be altered; looks like that was the only thing that was not altered.

Or, maybe it's not supposed to change, since I'm just facing 180 degrees prior to where I was facing, but my vector from my local point to north is still the same, and maybe my x and y only have to change since I now need to "face north"?

Can someone confirm my understanding...Thanks.

Re: Proof of Rotation Matrix for Sanity Purposes

Hey bigman8424.

If you rotate about the z axis then it means the z value should not change and the result you obtained makes sense.

If you want the z point altered you need to rotate around something that isn't the z axis.

To understand this, note that if you rotate a point that lies on the rotation axis, then rotating the axis (and the point) doesn't change any point on the axis. The further the point is away from the axis the more that the point will change after its rotation.

You need to have a rotation axis that makes sense intuitively for your purpose and use that to perform the rotation.