SRL Archive - Mathematics

Finding the Z Value of a Point in a triangle in 3D Space


Kasi

2012-11-02 21:13:24

Erm best way to describe it…


i only have the 3 corners and i know how to work out the center. any idea how to work out the random point?

riwu

2012-11-02 21:18:01

This looks like a 3D vector question.

First you have to find the equation of the plane. (Find 2 dir vector by the concept of AB=OB-OA)
Then just sub in 7,3,z to the plane eqn to form an eqn, and solve it.

That should be it, if you don't understand any step i can explain in greater detail.

Nebula

2012-11-02 21:21:49

Find the slope between the middle point and the lower right corner point. Then multiply the slope by the distance between the Random point and lower right corner point.

Kasi

2012-11-02 21:24:08

From: riwu
This looks like a 3D vector question.

First you have to find the equation of the plane. (Find 2 dir vector by the concept of AB=OB-OA)
Then just sub in 7,3,z to the plane eqn to form an eqn, and solve it.

That should be it, if you don't understand any step i can explain in greater detail.


Ahh making a game engine, needed in the culling bit -.- ill pm you

riwu

2012-11-02 21:51:22

From: Nebula
Find the slope between the middle point and the lower right corner point. Then multiply the slope by the distance between the Random point and lower right corner point.

The random point may not lie between the middle and the lower right corner. Also how you do find the 'slope' of a 3D plane? I get where your idea comes from, solving a linear eqn by finding the gradient then using formula like y=mx+c, y-y1=m(x-x1), practical for 2D but i don't think it works for 3D :p


To find the direction vector of the plane, take any 2 position vector and subtract them. (do this twice for 2 dir vector)
(5,7,10)-(10,2,7) = (-5, 5, 3)
(10,2,7)-(2,2,5) = (8, 0, 2)

Forming the eqn…1 position vector + (2 direction vector, where their prefix can be any real numbers).
r = (10, 2, 7) + a(-5,5,3) + b(8,0,2), where a and b are any real numbers.

Subbing in the unknown point…
(7,3,z) = (10, 2, 7) + (-5a, 5a, 3a) + (8b, 0, 2b)

Comparing the x-plane: 7 = 10 - 5a + 8b —-(1)
Comparing the y-plane: 3 = 2 -5a —-(2)
Solving the simultaneous eqn through elimination:
from (2): 5a = -1 => a = -1/5
sub 5a into (1): 7 = 10 -(-1) + 8b => b= -0.5
Actually in this case as value of b in eqn 2 is 0 the situation is easier, if not you have to sub back value of b into one of the eqn to find a.

Now that we have values for a and b, compare z-plane…
z = 7 + 3 (-1/5) + 2 (-0.5)
z = 5.4

Therefore the random point is (7, 3, 5.4).
I'm not sure if i made any careless mistake so do check the working :p
If you have doubts over any step i can explain them clearer too.

Nebula

2012-11-02 22:09:49

Didn't know the point would be random across the entire triangle, and I just glanced quickly at the drawing and assuming that the point was between the middle and lower right corner, and that the triangle was isosceles..

If for example, the middle point was (1, 4, 7) and the lower right corner point was (2, 0, 0) and the random point was (1.5, 2, ?) then

Slope between middle and lower right: (7 - 0) / (1 - 0) = 7
x Dist between random point and lower right: 2 - 1.5 = .5

7 * .5 = 3.5

of course that would only work under the circumstances I mentioned. Use your fancy formula and let me know if you get 3.5 aswell :) but of course for his game engine, your way is superior. I assumed the point was static.

riwu

2012-11-02 22:20:45

From: Nebula
Didn't know the point would be random across the entire triangle, and I just glanced quickly at the drawing and assuming that the point was between the middle and lower right corner, and that the triangle was isosceles..

If for example, the middle point was (1, 4, 7) and the lower right corner point was (2, 0, 0) and the random point was (1.5, 2, ?) then

Slope between middle and lower right: (7 - 0) / (1 - 0) = 7
x Dist between random point and lower right: 2 - 1.5 = .5

7 * .5 = 3.5

of course that would only work under the circumstances I mentioned. Use your fancy formula and let me know if you get 3.5 aswell :) but of course for his game engine, your way is superior. I assumed the point was static.

It means we will only be dealing with a line:
Dir vector of line: (1, 4, 7) - (2, 0, 0) = (-1, 4, 7)
r = (2, 0, 0) + a(-1, 4, 7)

Sub the unknown:
(1.5, 2, z) = (2 - a, 4, 7)

There is contraction in the eqn..the psedo x,y value of the random point you gave does not lie within the line, and it is non-collinear, no value of z would satisfy the eqn.

You can't simply calculate gradient by ignoring the other 2 dimensions, hard to explain this but if you have some 3D model, or maybe draw a graph you may be able to see it for yourself.

EDIT: sorry you are right that it's collinear, forget to multiply the y,z by a when i sub the unknown:
(1.5, 2, z) = (2-a, 4a, 7a)
a=0.5
7(0.5)= z => z=3.5

Although how you get your working (7 - 0) / (1 - 0)? z-plane of point 1 minus z-plane of point 2, divided by x-plane of point 1 minus y-plane of point 2?

Kasi

2012-11-02 22:30:54

So confused to even get my head around this -.- ill look at it in the morning.

Yakman

2012-11-05 17:15:00

Triangle is a 2d object, your space is 3d.

You don't have a triangle there, that's perhaps a triangular prism?

Kasi

2012-11-05 17:47:50

From: Yakman
Triangle is a 2d object, your space is 3d.

You don't have a triangle there, that's perhaps a triangular prism?


it's a triangle face if anything. if you want you can imagine it with a small depth. it makes up an actual 3d object. so like if it was a triangular prism then it would be one side of it.