Navigation: Scripting Reference Manual > Script Examples > Examples - General Ray Data

 

Examples - General Ray Data

 

Contact Us: fredsupport@photonengr.com

 

These examples cover the FRED general Ray Data scripting commands:

"Add" - add a ray buffer,

"Get" - retrieves information from a ray buffer,

"Set" - changes the active ray buffer.

 

The structure listed below contains the parameters required to define ray data:

T_RAY

 


 

"Add" a ray

 

The following example constructs polar grid of rays in the z=0 plane. Here the rays are positioned like the spokes of a wheel:

Dim r As T_RAY

nspokes=9    'number of spokes

nrings=5     'number of rings

aprad=2      'aperture radius
ang=2*Pi/nspokes
spc=aprad/nrings
Pi=Acos(-1)  'define Pi

'set z-position, power and make rays active (traceable)

r.z=0                  'set rays to be in the z=0 plane  
r.power=1
r.active=True
 

'center ray
r.x=0:r.y=0
id=AddRay(r)

'spokes

 For i=spc To aprad Step spc
  For j=0 To 2*Pi-(ang) Step ang
   r.x=i*Cos(j): r.y=i*Sin(j)
   id = AddRay ( r )
  Next j
 Next i
RaySummary             'print ray summary to verify creation


 

"Get" ray data

 

The "Get" commands are used to return either ray count or specific ray information.

 

Getting ray count involves a single command that returns the number of rays in the active ray buffer:

 

count=GetRayCount()

 

GetRay populates an existing T_RAY structure with the current ray parameters. The example below gets the data for ray 12 and places it in T_RAY structure r. Here, some of the data is printed to the output window.

 

Dim r As T_RAY

If IsRayLive(i) Then 

 GetRay 12, r

 Print r.x,r.y,r.z

 Print "The ray is active -", r.active

End If


 

"Set" a ray

 

Use "SetRay" to change the parameters of an existing ray. Here, ray number 35 is made inactive (nontraceable):

 

Dim r As T_RAY

r.active=False

SetRay 35, r


 

Looping over Rays

 

The recommended method of looping over rays is shown below. The commands GetFirstRay and GetNextRay retrieve individual ray data into the T_RAY structure. See Multi-Threaded Raytracing for further details on looping over rays.

 

success = GetFirstRay(i,tr)

While success

 :   :

 :   :

 success = GetNextRay(i,tr)

Wend

 


See Also….

Advanced Raytrace

Basic Raytrace

Coatings

Curves

Elements

Entity Info

Gratings

Importance Sampling

Linear Transforms

Materials

Ray Buffer Handling

Ray Data Get/Set

Ray Path

Raytrace Control

Scatter

Sources

Surfaces

 

 

 

 

 

Copyright © Photon Engineering, LLC