Does anyone know the formula for getting the z coordinate of the point on a triangle given the x and y coordinates of the point? Thank you.

# Formula to find point on the plane of a triangle given x and y coordinates?

Started by Portable591, Jul 09 2001 05:38 PM

5 replies to this topic

Sponsor:

###
#2
Members - Reputation: **864**

Posted 09 July 2001 - 06:37 PM

How is your triangle defined?

Even if you specify two corners - (x1,y1,z1) and (x2,y2,z2) - by only specifying (x3,y3,-) you are defining an infinite family of triangles. So, there must be more information you have neglected to give us.

Cheers,

Tim

Even if you specify two corners - (x1,y1,z1) and (x2,y2,z2) - by only specifying (x3,y3,-) you are defining an infinite family of triangles. So, there must be more information you have neglected to give us.

Cheers,

Tim

###
#3
Members - Reputation: **122**

Posted 09 July 2001 - 07:04 PM

The triangle is defined by 3 points each with an x, y, and z coordinate. Each of those 3 points are known. How would I find the z coordinate of a point that is located inside of the triangle if I knew the x and y coordinates of the point already? Hope that helps clarify it.

###
#4
Anonymous Poster_Anonymous Poster_*
Guests - Reputation:

Posted 09 July 2001 - 11:27 PM

assuming the triangle is not vertical to the xy plane, you could do that the following way:

your points are a,b,c, for the plane, and d for the point searched. make two direction vectors, ab and ac. add the two vectors to produce a new direction vector, e.

now, do: (using some c++ pseudocode)

d.z = d.x * e.x / e.z + d.y * e.y / e.z + a.z

and you have your z coordinate

(this SHOULD work, but if im wrong, tell me)

your points are a,b,c, for the plane, and d for the point searched. make two direction vectors, ab and ac. add the two vectors to produce a new direction vector, e.

now, do: (using some c++ pseudocode)

d.z = d.x * e.x / e.z + d.y * e.y / e.z + a.z

and you have your z coordinate

(this SHOULD work, but if im wrong, tell me)

###
#5
Members - Reputation: **122**

Posted 10 July 2001 - 11:06 AM

Use the plane equation:

A*(x-x0)+B*(y-y0)+C*(z-z0)=0

where P(x0,y0,z0)is a point that belongs to this plane and

N = [A,B,C] is a wector perpendicular to your plane.

So, P is one of triangles vertices. To find N calculate the cross

product of two wectors made of triangle''s vertices.

So, if triangles vertices are (x1,y1,z1) (x2,y2,z2) and (x3,y3,z3), N = V1 x V2 (x - cross product)

where V1 = [x2-x2,y2-y1,z2-z1], V2 = [x3-x1,y3-y1,z3-z1]

After that insert A,B,C values and known x and y coordinates into

plane equation. Rearange it, so you get

z = (C*z0 - A*(x-x0) - B*(y-y0))/C

Note, that C must be different from zero, otherwise this method

fails.

K.

A*(x-x0)+B*(y-y0)+C*(z-z0)=0

where P(x0,y0,z0)is a point that belongs to this plane and

N = [A,B,C] is a wector perpendicular to your plane.

So, P is one of triangles vertices. To find N calculate the cross

product of two wectors made of triangle''s vertices.

So, if triangles vertices are (x1,y1,z1) (x2,y2,z2) and (x3,y3,z3), N = V1 x V2 (x - cross product)

where V1 = [x2-x2,y2-y1,z2-z1], V2 = [x3-x1,y3-y1,z3-z1]

After that insert A,B,C values and known x and y coordinates into

plane equation. Rearange it, so you get

z = (C*z0 - A*(x-x0) - B*(y-y0))/C

Note, that C must be different from zero, otherwise this method

fails.

K.

###
#6
Members - Reputation: **864**

Posted 10 July 2001 - 03:55 PM

Grudzio's answer is basically correct. Just to make things a little clearer though and provide some understanding for those not familiar with the solution method...

The scalar equation of a plane having normal vector

a(x-x

Given P

ax + by + cz = d

where d = ax

Hence, rearranging gives

z = (d - (ax + by))/c

The stipulation that the plane not be vertical (and hence the normal not horizontal to (x,y) plane) means that c will not be zero. Obviously, if the plane is vertical, then specifying a single (x,y) coordinate cannot uniquely determine a z coordinate on the plane.

Hope this helps clear things up.

Cheers,

Tim

Edited by - Timkin on July 10, 2001 11:01:47 PM

The scalar equation of a plane having normal vector

**n**=(a,b,c) that passes through the point P_{o}=(x_{o},y_{o},z_{o}) is given by:a(x-x

_{o}) + b(y-y_{o}) + c(z-z_{o}) = 0Given P

_{o}and**n**we can obtain the linear relation of a plane (by collecting terms):ax + by + cz = d

where d = ax

_{o}+ by_{o}cz_{o}Hence, rearranging gives

z = (d - (ax + by))/c

The stipulation that the plane not be vertical (and hence the normal not horizontal to (x,y) plane) means that c will not be zero. Obviously, if the plane is vertical, then specifying a single (x,y) coordinate cannot uniquely determine a z coordinate on the plane.

Hope this helps clear things up.

Cheers,

Tim

Edited by - Timkin on July 10, 2001 11:01:47 PM