POV-Ray : Newsgroups : povray.general : Scope of declared identifiers? Server Time
22 Dec 2024 02:05:20 EST (-0500)
  Scope of declared identifiers? (Message 1 to 3 of 3)  
From: ab1jx
Subject: Scope of declared identifiers?
Date: 15 Dec 2018 13:10:01
Message: <web.5c1541eb8a1acc71d4251dfa0@news.povray.org>
New to the group, I've been playing with Povray on and off for 20 years or so.

I'm playing lately with cheap LEDs which can be found on Aliexpress under a
penny each.  But they mostly have narrow beam widths, like 10 - 20 degrees, so
you need to use a bunch of them, I'm trying to use Povray to model different
arrangements as a feasibility study before building them in real life.

I can do one LED and using scattering media I can have it project a beam of
light.  But I #declare an identifier called substrate (a box really) and use
that in a looks_like of the actual light source that casts a beam.  Except now I
want to do that dozens of times, with the entire LED translated and rotated.
Not only does substrate need to move but so does the point_at point of the
light_source.  That doesn't seem to be happening.

I #declare an object called ledbody and inside that I put the parts of the LED:
the pins (box), body (cylinder), tip (sphere), substrate (box) and the
light_source with looks_like {substrate}.  I'm currently defining substrate
inside ledbody, seems to work about the same as doing it outside.  I do the
whole thing at 0,0,0 and expect it to move and tilt with translate and rotate.

I'm not sure if one object can be declared as being part of another, but
looks_like for the light source needs an object (substrate).  The whole thing
needs to be an object so I can replicate it.  It looks like the point_at point
isn't moving, I only see beams from the first 2 LEDs.


Post a reply to this message

From: ab1jx
Subject: Re: Scope of declared identifiers?
Date: 15 Dec 2018 13:35:00
Message: <web.5c1548de9ea205e6d4251dfa0@news.povray.org>
"ab1jx" <ala### [at] gmailcom> wrote:
> New to the group, I've been playing with Povray on and off for 20 years or so.
>
> I'm playing lately with cheap LEDs which can be found on Aliexpress under a
> penny each.  But they mostly have narrow beam widths, like 10 - 20 degrees, so
> you need to use a bunch of them, I'm trying to use Povray to model different
> arrangements as a feasibility study before building them in real life.
>
> I can do one LED and using scattering media I can have it project a beam of
> light.  But I #declare an identifier called substrate (a box really) and use
> that in a looks_like of the actual light source that casts a beam.  Except now I
> want to do that dozens of times, with the entire LED translated and rotated.
> Not only does substrate need to move but so does the point_at point of the
> light_source.  That doesn't seem to be happening.
>
> I #declare an object called ledbody and inside that I put the parts of the LED:
> the pins (box), body (cylinder), tip (sphere), substrate (box) and the
> light_source with looks_like {substrate}.  I'm currently defining substrate
> inside ledbody, seems to work about the same as doing it outside.  I do the
> whole thing at 0,0,0 and expect it to move and tilt with translate and rotate.
>
> I'm not sure if one object can be declared as being part of another, but
> looks_like for the light source needs an object (substrate).  The whole thing
> needs to be an object so I can replicate it.  It looks like the point_at point
> isn't moving, I only see beams from the first 2 LEDs.

Never mind, probably.  I was running out of -Z in my box with the scattering
media.  I was angling the replications of the LED back toward the viewer and the
beam disappeared.  Then I thought about it and extended the box, now all 5 of
them show beams at least somewhat.


Post a reply to this message

From: Alain
Subject: Re: Scope of declared identifiers?
Date: 16 Dec 2018 14:33:53
Message: <5c16a8a1$1@news.povray.org>
Le 18-12-15 à 13:05, ab1jx a écrit :
> New to the group, I've been playing with Povray on and off for 20 years or so.
> 
> I'm playing lately with cheap LEDs which can be found on Aliexpress under a
> penny each.  But they mostly have narrow beam widths, like 10 - 20 degrees, so
> you need to use a bunch of them, I'm trying to use Povray to model different
> arrangements as a feasibility study before building them in real life.
> 
> I can do one LED and using scattering media I can have it project a beam of
> light.  But I #declare an identifier called substrate (a box really) and use
> that in a looks_like of the actual light source that casts a beam.  Except now I
> want to do that dozens of times, with the entire LED translated and rotated.
> Not only does substrate need to move but so does the point_at point of the
> light_source.  That doesn't seem to be happening.
> 
> I #declare an object called ledbody and inside that I put the parts of the LED:
> the pins (box), body (cylinder), tip (sphere), substrate (box) and the
> light_source with looks_like {substrate}.  I'm currently defining substrate
> inside ledbody, seems to work about the same as doing it outside.  I do the
> whole thing at 0,0,0 and expect it to move and tilt with translate and rotate.
> 
> I'm not sure if one object can be declared as being part of another, but
> looks_like for the light source needs an object (substrate).  The whole thing
> needs to be an object so I can replicate it.  It looks like the point_at point
> isn't moving, I only see beams from the first 2 LEDs.
> 
> 
> 

I'd build then from lights with the spot_light attribute.
Use half of the lower angle value as the radius, and the larger value as 
the falloff value. The spotlight need a point_at attribute that default 
to <0,0,0>.
You can make the light, then, rotate and translate it as needed.

Any light can be part of an union.

Sample for a scene scaled at about 1 unit = 1 cm :
#declare Sample_LED =
union{
  light_source{0, rgb<1,0.05,.02>*50
   fade_power 2 fade_distance 0.2
   area_light 0.1*x 0.1*y 9 9 adaptive 0 circular
   spotlight
   radius 5
   falloff 10
   point_at z
  }
  cylinder{<0,0,-0.2><0,0,0.6>, 0.3 hollow
   pigment{rgbf<1, 0.2, 0.2, 0.9>}
   interior{Some_Media ior 1.5}
   finish{diffuse 0.5, 0.33 ambient 0 specular 0.7 fresnel}
//Use backside illumination and have the IOR affect the highlights.
  }
}

You can always have a declared object within an union :
object{Declared_Object rotate Rotation translate Translation}

You can now use it as many times as you want. The direction of the beam 
will change according to any rotation provided, and get shifted by any 
translation.

Declaring some object within another one definition is valid, but I 
don't recommend it. It will be a distinct entity from the other object, 
and won't be affected by transformations applied to the other object. I 
highly prefer declaring it before, then use it in an union. Clearer and 
less risk of errors.

#declare OBJ1= box{-5 5 #declare OBJ2={sphere{0,1}}
will create 2 independent objects : OBJ1 and OBJ2.

If you have multiple instances of a light in an union and you rotate 
that union, then, all lights will also rotate by the same amount. Same 
goes for translations.

adaptive 0 don't turn the feature off, but start sampling with the 4 
corner elements, and take additional samples if needed.

For your media, don't change intervals from it's default of 1, but 
increase the samples value. The default samples value is 10 and must be 
at least 3.


Post a reply to this message

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