#### Archived

This topic is now archived and is closed to further replies.

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

This topic is 6033 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites

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

##### Share on other sites
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.

##### Share on other sites
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)

##### Share on other sites
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.

##### Share on other sites
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 n =(a,b,c) that passes through the point Po=(xo,yo,zo) is given by:
a(x-xo) + b(y-yo) + c(z-zo) = 0

Given Po and n we can obtain the linear relation of a plane (by collecting terms):

ax + by + cz = d

where d = axo + byo czo

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