#### Archived

This topic is now archived and is closed to further replies.

# Heightdefining

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

## Recommended Posts

Hi all, I''m constructing a RPG in sort of a Tomb Raider type 3d engine. My question is if i have a square with 4 corners that differ in height and the X-Z coordinates (in a 0-1scale) where the player currently is the square. How do I in the fastest possible way calculate the Y coordinate based on where the player is in relation to the objects edges. EX: y0 y1 ______________ | | | | | | | | | x | |______________| y2 y3 x=playerpos Regards Fredrik

##### Share on other sites
y1 + y2 + y3 + y4 / 4

##### Share on other sites
Well, sorry I didn´t really read your post well. I don't know if this is the fastest way to do it:

(y0 * px * pz + y1 * (1-px) * pz + y2 * px * (1-pz) + y3 * (1-px) * (1-pz)) / 4

Where px and pz are the player coordinates.

Nick

Edited by - nickm on October 18, 2001 3:04:48 PM

Edited by - nickm on October 18, 2001 3:05:18 PM

##### Share on other sites
You shouldn''t divide by 4. If n=y0=y1=y2=y3 then y(x,z) = nxz + nx(1-z) + n(1-x)z + n(1-x)(1-z) = nxz + nx - nxz + nz - nxz + n -nz - nx + nxz = n not n/4. The center would be (y0+y1+y2+y3)/4.

##### Share on other sites
Yeah you''re absolutely right... You know, I was really tired (almost sleeping) when I posted that message

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 29
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002290
×