Jump to content
  • Advertisement
Sign in to follow this  
kaarigar

Coordinate transformation question

This topic is 2118 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.. 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!