I am working on an engine that will draw lightmaps.

How can I find point on the plane of triangle that is the closest to my light source?

# Need help with geometry...

The point you’re looking for is the intersection between your triangle plane and the line passing through the light in the direction of your plane normal.

I understand that, but can anyone write the

formula?(PLEEEAASE!)

It must be true that for any plane with unit normal n=[a b c] and displacemet d, that if a point p=[X Y Z] is in the plane, then the following equation must be satisfied:

a*X+b*Y+c*Z=d

Ok, that is in otherwords the equation of the plane. Next you have a line defined by the point of light L=[lx ly lz] and normal of the plane in question, n=[a b c]. A parametric equation of the line l is:

l=L + s * n

So for any given s, l(s) is some point on the line (ray of light if you will) and expands into three equations of course. All you need to do is take those three equations and plug them into X, Y, and Z, solve the resulting equation for s, then plug that s back into the equation of the line to find the point l(s). This point is the point at which the line intersects the plane of the polygon and is parallel to the normal of the plane.

[This message has been edited by DFrey (edited 01-08-2001).]

I think what DFrey said can be implemented this way:

Well, suppose that the light is L, the 3 points of the triangle are A, B and C. The point of the triangle’s plane that is nearest to the light is P. Then you do the following:

CA = A - C

CB = B - C

CL = L - C

N = CA X CB ( where ‘X’ is the cross product operator)

NN = N.N ( where the dot ‘.’ is the dot product operator)

F = - CL.N/NN

finally,

P = L - F*N

If I’m wrong please point that out.