# finding ground height ?

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

## Recommended Posts

I have my world with vertices (V[0], V[1] , V[2]) and respective normal (normal), my player's position is (position), can anyone describe me an algoritm to "find height" from player postition to the ground ? I have used plane distance ecuation: Ax+Bx+Cx+D = 0, but I just confussed with that... _O_ | / \ --- | | h | | ---------------------

##### Share on other sites
Your plane equation is wrong. Should be:

Ax + By + Cz + D = 0

Do you know how to compute the plane equation for your ground plane?

So, to find the height, let's say your player is at some point, say, <45, 100, 115>. To find the "height" above the ground, do the following. I am assuming that your "up" direction is positive Z.

1) Compute the ground elevation, the ground's Z value, at the player's xy location. Solving algebraically:

z_ground_below_player = -(D +Ax +By) / C;

You know everything on the right-hand-side, so can solve for z

2) The "height" above terrain is:

height_above_ground = z_player - z_ground_below_player

Or, in this case:

height_above_ground = 115 + ((D + Ax + By) / C);

Hope that helps!

##### Share on other sites

I dont need to compute the ground normals to do that ?
How do I compute A ,B C and D of plane ecuation? Can you help me?

##### Share on other sites
Actually, for the plane equation, you do need a normal. So, the A, B, and C are the plane normal = (A,B,C). If the ground is horizontal and positive Z is "up", then (A,B,C) = (0,0,1). If the ground is sloped, then you have to have the ground defined in some way that you know the slope.

To find D, you have to know a point that is on the plane. So, if, say, positive Z is up and the ground is at z = 15, then the point (0,0,15) is on the plane and so:

Ax+By+Cz+D = 0 = 0x+0y+1z+D = z+D

So, then z+D = 0 and D = -z, or

D = -15

That gives you a final equation of::

0x+0y+1z-15 = 0, or z = 15 for all xy. This makes sense for a horizontal ground plane, that z is the same no matter what xy you are at. If you have a sloped ground then (A,B,C) will be different and it will be a bit more interesting.

##### Share on other sites
Thank you very much, here is my mail: programar3d@yahoo.com.ar

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 32
• ### Forum Statistics

• Total Topics
632630
• Total Posts
3007526
• ### Who's Online (See full list)

There are no registered users currently online

×