Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Navigating in a rotated grid?
Replies: 3   Last Post: Nov 17, 2010 7:03 AM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 JS Posts: 49 Registered: 8/4/08
Navigating in a rotated grid?
Posted: Nov 15, 2010 3:08 PM
 Plain Text Reply

Hi NG,

I have now struggled with a problem for a while so I finally resort to
asking here in the hope somebody can help me, or at least give a few
pointers. The problem is very simple, so I hope there is a simple
solution also, that I just haven't seen. Here goes:

I have a list of coordinates (X,Y,Z) which I know form a rectangular
grid with all datapoints within that rectangle existing in the list.
However, the grid is rotated and translated, relative to a "normal"
coordinate system. That is, if I do scatter(X,Y), I see the rectangle
as a diamond shape (i.e., rotated) and shifted away from the origin
(i.e., translated). The points are equally spaced.

What I would like is a matrix with the surface formed by the
coordinates (X,Y,Z) so that row 1 in the matrix corresponds to all the
Z values found along the lower edge of the rectangle, row 2
corresponds to the next row up, etc. In effect, I am thereby defining
my own coordinate system like this, with axes parallel to the sides of
the rectangle. Simple as that. Had the data not been rotated, this
would of course be trivial, but since it is, I can't "travel" along,
e.g., a row in the rotated grid and copy the Z values over to the
right spot in a matrix, since a row is not a row in the "straight"
coordinate system.

I of course know the angle and offset so I have tried to simply shift
all points so that the lower left corner has (0,0) and then rotate the
points with:

xCoordsRot = (xCoords.*cosd(rotAngle))-(yCoords.*sind(rotAngle));
yCoordsRot = (xCoords.*sind(rotAngle))+(yCoords.*cosd(rotAngle));

This works, however, this is not a very "nice" result, in that there
are rounding issues causing the point spacing that I know to be an
even number (500) no longer to be so. This, in turn makes is difficult
to find the correct coordinates in my matrix for a given Z value.

So, how can I move around along a row in a rotated grid in a simple,
efficient manner? Any suggestions?

Thanks very much in advance!

/JS

Date Subject Author
11/15/10 JS
11/16/10 JS
11/16/10 Curious
11/17/10 JS

© The Math Forum at NCTM 1994-2018. All Rights Reserved.