Posted By: Carlos3DGS
[SOLVED] Triangle height math problem? - 11/02/11 16:54
I have a problem with some triangle math, I was recommended a couple of functions to use to solve it (vec_lerp for its height and vec_dot for its angle).
Diagram of the problem:

I have been reading both functions and am trying to come up with a clever way to implement it but I have to admit I have absolutely no idea what to do...
Here is my problem:
lets say this is a 16x16 square formed by these 4 vectors:
A=(0,15,6)
B=(15,0,7)
C=(15,15,0)
D=(0,0,-1)
the coords are (x,y,height)
How would I calculate the height of H1 and H2 if I only have their xy coordinates to work with?
H1=(3,11,?)
H2=(13,3,?)
I assume the first step would be to calculate which triangle H1 or H2 are on?
How could I calculate if H1 is inside triangle ACD or BCD?
How could I calculate if H2 is inside triangle ACD or BCD?
Diagram of the problem:

I have been reading both functions and am trying to come up with a clever way to implement it but I have to admit I have absolutely no idea what to do...
Here is my problem:
lets say this is a 16x16 square formed by these 4 vectors:
A=(0,15,6)
B=(15,0,7)
C=(15,15,0)
D=(0,0,-1)
the coords are (x,y,height)
How would I calculate the height of H1 and H2 if I only have their xy coordinates to work with?
H1=(3,11,?)
H2=(13,3,?)
I assume the first step would be to calculate which triangle H1 or H2 are on?
How could I calculate if H1 is inside triangle ACD or BCD?
How could I calculate if H2 is inside triangle ACD or BCD?