I Putting a point inside a triangle in 3D space

AI Thread Summary
To compute the y-coordinate of a point p4 in a plane defined by three points in 3D space, one efficient method involves using the cross product of vectors formed by the triangle's edges to derive the plane's equation. Once the plane is established, substituting the known x and z coordinates allows for solving the linear equation to find y. To maintain the relative position of p4 as the triangle moves, it can be expressed in terms of the triangle's vertices and the parameters a and b, which represent the barycentric coordinates. This method also facilitates checking if p4 lies within the triangle by ensuring the conditions on a and b are met. Overall, this approach provides a more elegant solution than using a determinant of a matrix.
wukunlin
Gold Member
Messages
478
Reaction score
117
This may belong to the computing subforum, let me know if this is more true than having it here in the math forum :)

My questions are
1) Suppose there is a plane in 3D space and I have 3 points to define it:
p1 = {x1, y1, z1}
p2 = {x2, y2, z2}
p3 = {x3, y3, z3}

and I want to put a particular point p4 which I already know the x- and z- coordinates.
What will be the most efficient way to compute the y- coordinate of p4?
I can think of the nasty method which I compute the determinant of a 4x4 matrix to find the coefficients for:
ax + by + cz + z = 0
Then substitute my known x and z, I get the feeling this is very inefficient and there are more elegant solutions than this. Are there any known algorithms to deal with this problem?

2) Now that I have my p4, I want have the same relative position to the 3 points p1, p2, p3 if someone move this triangle around:
f(p1, p2, p3) = p4
for example, if p4 happens to be in the middle of the triangle, the function would be the average of each of the x, y, z coordinates of the 3 points. But for a point that is off-centered, how will I go about finding what this function should be?
 
Mathematics news on Phys.org
so you have three points represented by three position vectors. If you subtract p1-p2 and p3-p2 then you have two vectors that describe the edges of the triangle right? If you then add them and divide the resultant vector by some value > 2 then what can you conclude?
 
  • Like
Likes wukunlin
It's possible there are more efficient ways, but here is a straightforward way. If you have three points in a plane ##P_1, P_2, P_3##, find displacement vectors between any two pairs of them, say, ##\vec u = \vec{P_1P_2}## and ##\vec v = \vec{P_1P_3}##.
Calculate the cross product ##\vec n = \vec u \times \vec v## = <A, B, C>
The equation of the plane will be ##A(x - x_1) + B(y - y_1) + C(z - z_1) = 0##, where I arbitrarily chose the coordinates of point ##P_1##. You could use the coordinates of either of the other two given points -- it doesn't matter.
Now that you have the equation of the plane, it's a simple matter to check whether some point ##P_4 = (x_4, y_4, z_4)## lies in the plane by substituting these coordinates for x, y, and z respectively in the plane's equation.
 
  • Like
Likes wukunlin and jedishrfu
wukunlin said:
This may belong to the computing subforum, let me know if this is more true than having it here in the math forum :)

My questions are
1) Suppose there is a plane in 3D space and I have 3 points to define it:
p1 = {x1, y1, z1}
p2 = {x2, y2, z2}
p3 = {x3, y3, z3}

and I want to put a particular point p4 which I already know the x- and z- coordinates.
What will be the most efficient way to compute the y- coordinate of p4?
I can think of the nasty method which I compute the determinant of a 4x4 matrix to find the coefficients for:
ax + by + cz + z = 0
Then substitute my known x and z, I get the feeling this is very inefficient and there are more elegant solutions than this. Are there any known algorithms to deal with this problem?

2) Now that I have my p4, I want have the same relative position to the 3 points p1, p2, p3 if someone move this triangle around:
f(p1, p2, p3) = p4
for example, if p4 happens to be in the middle of the triangle, the function would be the average of each of the x, y, z coordinates of the 3 points. But for a point that is off-centered, how will I go about finding what this function should be?

I am not sure I understand, the equation of a plane in 3-space is : ## ax+by+cz=d ##. Once you do the cross-product and have any of these points, you will have all of a,b,c and d given. You only need to solve for y from a linear relation. EDIT: Essentially a rewording of what Mark44 said.
 
  • Like
Likes wukunlin
If your triangle is aligned with the y-axis there is no unique solution, but if we know we don't have this special case:

To just find the third coordinate, set up the plane as described in the previous posts, this gives a linear equation to solve. Note: It doesn't guarantee you that the point is actually within the triangle.

To (a) check that the point is indeed inside and (b) make the triangle movable, I would take a slightly different approach.
With ##\vec u## and ##\vec v## defined as in post 3, the point 4 can be expressed as ##p_4 = p_1 + a \vec u + b \vec v## where ##a,b \geq 0## and ##a+b \leq 1##. If you consider the x and z coordinate of this equation you get two equations with two unknowns (a and b). Solve, and you can calculate the missing y coordinate. You can also check if the point is really within the triangle by checking the inequalities mentioned before. Shifting the triangle just changes ##p_1, \vec u, \vec v## so you can use the same a and b to find the new point 4.
 
  • Like
Likes wukunlin
I really appreciate all the help everyone. It made me realize how rusty the gears of my brain has gotten after years of not doing problems like these.

mfb said:
If your triangle is aligned with the y-axis there is no unique solution, but if we know we don't have this special case:

To just find the third coordinate, set up the plane as described in the previous posts, this gives a linear equation to solve. Note: It doesn't guarantee you that the point is actually within the triangle.

To (a) check that the point is indeed inside and (b) make the triangle movable, I would take a slightly different approach.
With ##\vec u## and ##\vec v## defined as in post 3, the point 4 can be expressed as ##p_4 = p_1 + a \vec u + b \vec v## where ##a,b \geq 0## and ##a+b \leq 1##. If you consider the x and z coordinate of this equation you get two equations with two unknowns (a and b). Solve, and you can calculate the missing y coordinate. You can also check if the point is really within the triangle by checking the inequalities mentioned before. Shifting the triangle just changes ##p_1, \vec u, \vec v## so you can use the same a and b to find the new point 4.
That worked beautifully! Thank you :biggrin:

WWGD said:
I am not sure I understand, the equation of a plane in 3-space is : ## ax+by+cz=d ##. Once you do the cross-product and have any of these points, you will have all of a,b,c and d given. You only need to solve for y from a linear relation. EDIT: Essentially a rewording of what Mark44 said.
Thanks for the help. Looks like great minds think alike :woot:

Mark44 said:
It's possible there are more efficient ways, but here is a straightforward way. If you have three points in a plane ##P_1, P_2, P_3##, find displacement vectors between any two pairs of them, say, ##\vec u = \vec{P_1P_2}## and ##\vec v = \vec{P_1P_3}##.
Calculate the cross product ##\vec n = \vec u \times \vec v## = <A, B, C>
The equation of the plane will be ##A(x - x_1) + B(y - y_1) + C(z - z_1) = 0##, where I arbitrarily chose the coordinates of point ##P_1##. You could use the coordinates of either of the other two given points -- it doesn't matter.
Now that you have the equation of the plane, it's a simple matter to check whether some point ##P_4 = (x_4, y_4, z_4)## lies in the plane by substituting these coordinates for x, y, and z respectively in the plane's equation.
Oh wow, that does look a LOT more elegant.

jedishrfu said:
so you have three points represented by three position vectors. If you subtract p1-p2 and p3-p2 then you have two vectors that describe the edges of the triangle right? If you then add them and divide the resultant vector by some value > 2 then what can you conclude?
Drawing that final vector from P2 will end up somewhere inside the triangle right?
 
  • Like
Likes WWGD
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Suppose ,instead of the usual x,y coordinate system with an I basis vector along the x -axis and a corresponding j basis vector along the y-axis we instead have a different pair of basis vectors ,call them e and f along their respective axes. I have seen that this is an important subject in maths My question is what physical applications does such a model apply to? I am asking here because I have devoted quite a lot of time in the past to understanding convectors and the dual...
Thread 'Imaginary Pythagoras'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...
Back
Top