• Create Account

Coordinate transformation question

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

#1kaarigar  Members   -  Reputation: 126

Like
0Likes
Like

Posted 03 October 2013 - 10:03 AM

Pardon my description of a problem - I am not necessarily a math expert. This could be a very easy problem to solve but I am not good at it at all.

I have a DTM (digital terrain model) that is represented by a regular matrix of points that have (x,y,z). I also have an elevation profile between two points (Pt1, Pt2, both on the XY plane) that is formed by cutting vertically through the DTM - the cutting plane is vertical to the XY plane and is passing through Pt1 and Pt2. This elevation profile represents the undulation of the ground between points Pt1 and Pt2 as series of 3D points in the same coordinate space as the DTM itself. I am able to do this using a commercial GIS software.

Now here's the question. I want to treat these set of points in the elevation profile in their own 2D coordinate system (which is the cutting plane described above) such that the

(1) Pt1 is the origin

(2) Pt1-Pt2 forms the the X axis

(3) Current Z axis (of the 3D coordinate space of DTM) forms the Y axis.

I hope I have been clear to describe this problem. Can someone please suggest how to go about solving this? Thanks!

#2Álvaro  Crossbones+   -  Reputation: 7964

Like
0Likes
Like

Posted 03 October 2013 - 10:34 AM

I assume you are working on a flat Earth. If you are working with realistic geography that curves with the planet, we'll have to be more careful.

A point (X,Y) in your new coordinates represents a point that can be computed as Pt1 + (Pt2-Pt1) * X + (0,0,1) * Y. Now you have a target point P and want to find the X and Y that make that work. Let's start with the following manipulation, to place the origin at Pt1:

P = Pt1 + (P - Pt1)

Now our job is to express the vector (P - Pt1) as a linear combination of (Pt2-Pt1) and (0,0,1). Since Pt1 and Pt2 both live in the XY plane, this means they don't contribute to the third coordinate, and therefore Y is just the old Z coordinate. To compute X you could use either of the two first coordinates by itself, or you could use the dot product to make things a little more robust (but the mathematician in me thinks it's inelegant to use the dot product, since the whole problem so far was in the realm of affine geometry).

Let me know if you can finish from there.

#3kaarigar  Members   -  Reputation: 126

Like
0Likes
Like

Posted 03 October 2013 - 12:32 PM

I assume you are working on a flat Earth. If you are working with realistic geography that curves with the planet, we'll have to be more careful.

A point (X,Y) in your new coordinates represents a point that can be computed as Pt1 + (Pt2-Pt1) * X + (0,0,1) * Y. Now you have a target point P and want to find the X and Y that make that work. Let's start with the following manipulation, to place the origin at Pt1:

P = Pt1 + (P - Pt1)

Now our job is to express the vector (P - Pt1) as a linear combination of (Pt2-Pt1) and (0,0,1). Since Pt1 and Pt2 both live in the XY plane, this means they don't contribute to the third coordinate, and therefore Y is just the old Z coordinate. To compute X you could use either of the two first coordinates by itself, or you could use the dot product to make things a little more robust (but the mathematician in me thinks it's inelegant to use the dot product, since the whole problem so far was in the realm of affine geometry).

Let me know if you can finish from there.

Yes, I am assuming flat earth at this point.

I understand that Y of the new point would be the Z of the old point. Your description of finding the new X, I find following confusing -

To compute X you could use either of the two first coordinates by itself, or you could use the dot product to make things a little more robust (but the mathematician in me thinks it's inelegant to use the dot product, since the whole problem so far was in the realm of affine geometry).

Can you elaborate on that? Can I just use the Pt1 + (Pt2-Pt1) * X + (0,0,1) * Y ignoring the Z component of Pt1 and Pt2 and get the transformed point?

#4Álvaro  Crossbones+   -  Reputation: 7964

Like
1Likes
Like

Posted 03 October 2013 - 12:55 PM

P = Pt1 + (Pt2-Pt1) * X + (0,0,1) * Y is actually three equations, one per coordinate:

P.x = Pt1.x + (Pt2.x-Pt1.x) * X

P.y = Pt1.y + (Pt2.y-Pt1.y) * X

P.z = Pt1.z + Y

You can use either of the first two equations to find X. If you use the first one, you get

X = (P.x - Pt1.x) / (Pt2.x-Pt1.x)

Notice that Pt2.x-Pt1.x could be zero or a very small number, and dividing by it might not be reasonable. So I would pick the first equation or the second one depending on whether abs(Pt2.x-Pt1.x) > abs(Pt2.y-Pt1.y) or not.

Edited by Álvaro, 03 October 2013 - 12:56 PM.

#5kaarigar  Members   -  Reputation: 126

Like
0Likes
Like

Posted 03 October 2013 - 11:15 PM

Thanks, Alvaro! As you pointed out, I see that if the Pt1-Pt2 form a vertical or a horizontal line, one of the appropriate equations to find X would need to be chosen accordingly. I am giving this a try right now and will report how it goes..

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS