well, radiosity is very similar to what you imagined. but what i'm actually
trying to do is quite different. indeed, even in radiosity you need
ray-tracing as the final step.
i was trying to create an engine that won't need it at all.
what i needed to understand was: "ok, i have a ray and a 3d plane (the
screen). i also have the intersection of the ray and the plane. that's
(x,y,z). now, which pixel do i have to color in the output bitmap?"
> > absolutely not real-time. it's a sort of radiosity algo.
> > yeah i know. maybe i'm completely OT here. i just hoped someone could help.
[quoted text clipped - 10 lines]
>
> Peter
> well, radiosity is very similar to what you imagined. but what i'm actually
> trying to do is quite different. indeed, even in radiosity you need
[quoted text clipped - 3 lines]
> screen). i also have the intersection of the ray and the plane. that's
> (x,y,z). now, which pixel do i have to color in the output bitmap?"
Okay, well that's quite simple - you have the plane in 3D space, you
need to translate back into pixels. You do that parametrically. You
have the intersection (P) of the ray and the plane (VP) so convert the
offset of P relative to VP into a pair of x,y values in the VP frame of
reference (in the range 0-1) and multiply these values by the screen
dimensions to get to pixels.
To convert P,VP into an x,y cordinates:
Your plane is (A,B,C,D)
The point is P
x,y are the unknowns
A | B
| y
--------P
x
D C
The distance AP calculated using vector math (distance between A and P
is the magnitude of (A-P))
The angle between AP and AB can be calculated using the dot product.
The general rule is:
r.q = |r| |q| cos(theta)
so we can get the angle from the dot product by rearanging:
cos(theta) = r.q / (|r| |q|)
Once you have the angle of BAP and the length of AP you can find out the
Y cordinate using trig:
sin(theta) = y / |AP|
.: y = sin(theta) * |AP|
You can calculate x in a similar way (angle PAD is 90 - BAP) so:
sin(90-theta) = x / |AP|
.: x = sin(90-theta) * |AP|
Thats how I figure it anyway, hopefully I haven't made any mistakes.
Don't forget to normalise the vectors before using the dot product to
get angles.
HTH
Peter.
Peter Ashford - 02 Mar 2004 23:42 GMT
This might be obvious, but I forgot to mention: those x,y values relate
to the VP frame, they need to be normalised to lie in [0..1]
CAFxX - 07 Mar 2004 19:52 GMT
> Your plane is (A,B,C,D)
>
[quoted text clipped - 11 lines]
> The distance AP calculated using vector math (distance between A and P
> is the magnitude of (A-P))
I really can't understand the drawing. Morover, in the "distance between A
and P" i can't figure out what A is. The plane? Wasn't it VP? Something
else?
Peter Ashford - 07 Mar 2004 22:45 GMT
>>Your plane is (A,B,C,D)
>>
[quoted text clipped - 13 lines]
>
> I really can't understand the drawing.
(A,B,C,D) is the plane VP. The formatting got stuffed up in posting,
I'm afraid.
Just use a proprtional font and push points B and C out to the right.
There is a horizontal line to point P and a vertical line (using the |
characters) from the top of the rectangle to P.
Morover, in the "distance between A
> and P" i can't figure out what A is. The plane? Wasn't it VP?
A is the top left coordinate of the plane. Points A,B,C,D are the four
corners of the plane.
Sorry its taken me so long to reply - I've been out of town on business.