PDA

View Full Version : 3D triangle interpolation



pipo
05-25-2001, 11:37 PM
Hello

I have the ollowing problem:
Given the three 3d vertices of a triangle and a point x, y, z inside the triangle: What is the fastest way to interpolate (eg edge-point intenities) for the point x,y,z?

Thanks a lot

Pipo

styx
06-08-2001, 12:38 PM
>Given the three 3d vertices of a triangle and a point x, y, z inside the triangle: What is the >fastest way to interpolate (eg edge-point intenities) for the point x,y,z?

hmm, maybe you express more exact what you are going to do ?

ffish
06-09-2001, 06:18 AM
Dunno if it's the fastest way, but here's the standard linear algebra way that I'd do it:



B
| \
| \
| \
| \
| \
| \
| .P \
| /| \
| / | \
A---------C
X

If you have a triangle with vertices A, B, C and a point in the middle P and you want to find the point X on a side then you need to do this:
(i) Use a local coordinate system for each point e.g. set the origin at A so you have the vector C.
(ii) You also have the vector P.
(iii) Calculate the projection of P onto C using the formula X = {C'*P/(C'*C)}*C where ' is the transpose and * is vector multiplication (i.e. you can just swap the '* symbols for dot product).
(iv) The part inside the curly brackets gives you the distance along CA to X from A.
(v) Interpolate intensities.
(v) Repeat twice so you have points X, Y and Z, one for each edge of the triangle.

I'd be interested if anyone else has any faster methods.

Hope that helps.

<edit>ASCII art didn't turn out too well http://www.opengl.org/discussion_boards/ubb/frown.gif</edit>

<edit2>Found a better explanation than mine with diagrams and stuff at http://astronomy.swin.edu.au/pbourke/geometry/pointline/</edit2>

[This message has been edited by ffish (edited 06-09-2001).]

[This message has been edited by ffish (edited 06-09-2001).]