So I have a light source, and a plane of sorts. Like this:
|
|
|
o |
|
|
|
Plane is represented by |
, and the light source is o
Now I am able to find the direction vector (is that the right term?) by subtracting the top left corner of the plane by the position of the light, like so:
vec3 dir = plane_top_left - light_pos
However, I want to be able to project the direction vector onto a farther plane, like so:
| /___ I want to know where this is
/| \
/ |
/ |
/ |
/| |
/ | |
/ | |
o | |
| |
| |
| |
How do I know where the direction vector and the plane intersect? By the way, this is a top-down view of a 3D scene
I have looked this up on google, and became extremely confused.... answers were conflicting, and I can barely understand the math behind them.
I don't think this has anything to do with C
specifically...
Here's what I can offer with my knowledge of space geometry: As you have said, the non-unit direction vector would be obtained by subtracting the coordinates of the initial point from the target point. Let's denote the top-left corner of your plane with TLC
and the light source with LS
. The non-unit direction vector would then be:
( TLC - LS )
In a three-dimensional system, this would be equivalent to:
< TLC_X - LS_X,
TLC_Y - LS_Y,
TLC_Z - LS_Z >
The answer for your question depends on how far the plane you want to project the light is. If it is 7/3
times as far as the original plane as in your diagram, then you could simply multiply the direction vector with that factor, and add that to the LS
:
LS + ( TLC - LS ) * 7 / 3
Whatever you do, you'll have to add that to LS
since it is the point of origin for the light. Depending on how far the projected plane is, the factor of multiplication will change. In general, it will be:
LS + ( TLC - LS ) * ( how_far_the_projected_plane_is / how_far_the_original_plane_is )