Results 1 to 10 of 10

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

  1. #1
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

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

    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?

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    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.

  3. #3
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    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.

  4. #4
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    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

  5. #5
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Nebula View Post
    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


    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
    If you have doubts over any step i can explain them clearer too.

  6. #6
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    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.
    Last edited by Nebula; 11-03-2012 at 02:12 AM.

  7. #7
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Nebula View Post
    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?

  8. #8
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

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

  9. #9
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

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

    You don't have a triangle there, that's perhaps a triangular prism?
    Join the Official SRL IRC channel. Learn how to Here.

  10. #10
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Quote Originally Posted by Yakman View Post
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •