POV-Ray : Newsgroups : povray.newusers : area light vectors Server Time
24 Nov 2024 08:34:18 EST (-0500)
  area light vectors (Message 1 to 4 of 4)  
From: stevenvh
Subject: area light vectors
Date: 21 May 2009 13:55:01
Message: <web.4a1594d11e27adc7c0721a1d0@news.povray.org>
Given my light source position (P1) and the center of my scene (P2), how do I
define the vectors of an area light?
TIA
Steven


Post a reply to this message

From: stevenvh
Subject: Re: area light vectors
Date: 21 May 2009 14:10:00
Message: <web.4a1598d1f95db164c0721a1d0@news.povray.org>
"stevenvh" <nomail@nomail> wrote:
> Given my light source position (P1) and the center of my scene (P2), how do I
> define the vectors of an area light?

.... er, that is, if I want the area light perpendicular with P2-P1.

Steven


Post a reply to this message

From: Chris B
Subject: Re: area light vectors
Date: 21 May 2009 14:37:03
Message: <4a159f4f@news.povray.org>
"stevenvh" <nomail@nomail> wrote in message 
news:web.4a1594d11e27adc7c0721a1d0@news.povray.org...
> Given my light source position (P1) and the center of my scene (P2), how 
> do I
> define the vectors of an area light?
> TIA
> Steven

If it's a circular area light and it meets the constraints listed in the 
help then you might be able to simply use the orient keyword.

Otherwise you can calculate two vectors that are perpendicular to (P2-P1). 
There are quite a few approaches that could do the job, so someone may well 
have a simpler method, but you can get a vector that's at right angles to 
P2-P1 and then get another that's at right angles to the two you've then got 
by using macros from the 'math.inc' include file that comes with POV-Ray:

#declare Vector1 = VPerp_To_Vector(P2-P1);
#declare Vector2 = VPerp_To_Plane(Vector1, P2-P1);

This assumes P1 isn't directly above or below P2.
That will give you unit length vectors that you'll need to multiply by 
whatever factors you want for the area light size.

If your area light is non-square you may want one of those vectors to be 
horizontal in which case you could use:

#declare IntermediaryHorizontalVector = VProject_Plane(P2-P1,y);
#declare Vector1 = VPerp_To_Plane(P2-P1,IntermediaryHorizontalVector);
#declare Vector2 = VPerp_To_Plane(Vector1, P2-P1);

(Look out for syntax errors and other typos 'cause I didn't run this through 
POV-Ray to check the code at all.)

Regards,
Chris B.


Post a reply to this message

From: clipka
Subject: Re: area light vectors
Date: 21 May 2009 15:40:01
Message: <web.4a15ada7f95db164e1d5d3040@news.povray.org>
"stevenvh" <nomail@nomail> wrote:
> "stevenvh" <nomail@nomail> wrote:
> > Given my light source position (P1) and the center of my scene (P2), how do I
> > define the vectors of an area light?
>
> .... er, that is, if I want the area light perpendicular with P2-P1.
>
> Steven

Assuming that you don't intend to use the "orient" keyword, you can compute the
X and Y of the are light source as follows:

(1) choose an "Up" vector you want your area light Y to be "as close as
possible" to, e.g.

  #declare Up = <0,1,0>;

(Make sure your "Up" vector is not parallel to P2-P1, or the following steps
will give you mashed potatoes.)

(2) choose your area light's "X" vector to be perpendicular to the direction
P2-P1 and the Up vector:

  #declare AreaLightX = vnormalize(vcross(P2-P1, Up)) * AreaLightSize;

(3) choose your area light's "Y" vector to be perpendicular to the direction
P2-P1 and the X vector:

  #declare AreaLightY = vnormalize(vcross(P2-P1, X)) * AreaLightSize;


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.