Navigation: Scripting Reference Manual > Script Examples > Example - Advanced Raytrace

 

Example - Advanced Raytrace

 

Contact Us: fredsupport@photonengr.com

 

These examples cover the FRED Advanced Raytrace scripting commands:

"Init" - initializes a raytrace structure,

"Advanced" - performs an advanced raytrace,

"Targeted" - performs a targeted raytrace.

 

The structures listed below contain the parameters required to define the advanced raytrace type:

T_ADVANCEDRAYTRACE

T_TARGETEDRAY
 


 

"Init" a raytrace

Both "Advanced" and "Targeted" raytraces have structures which define their required set of parameters. Of course, these parameters can be altered or tailored to the users needs, but FRED requires their structures be initialized first.

 

In this example, rays are traced through four intersections starting at object "Mirror2". FRED is told to perform the transmit/reflect operation at the ending surface and keep the ray history information.

 

Dim art As T_ADVANCEDRAYTRACE

InitAdvancedRaytrace art

 

art.startSurfID=FindName("Mirror2")

art.hitCount=4

art.transmitReflectOnStop=True

art.rayHistory=True

 

 

In the following example, the starting, ending and hint positions are given for an iterated ray to be traced to the "detector" surface. Note that the end position is specified here in the "detector" coordinate system.

 

Dim tr As T_TARGETEDRAY

InitTargetedRay tr

 

tr.startX=2:tr.startY=1:tr.startZ=-4      'staring position in object space

tr.endX=2:tr.endY=-1:tr.endZ=0            'ending position in image space

tr.hintType="Position"                    'positional hint

tr.hintX=0:tr.hintY=0:tr.hintZ=0          'start iteration by aiming at this position

tr.startCoordSys=-1                       'starting hints are in global

tr.targetSurface=FindName("detector")     'ray terminates on this surface

tr.endCoordSys=FindName("detector")       'end position is in detector's coordinate system

 


 

"Advanced" raytraces

 

The "AdvancedRayTrace" command instructs FRED to perform an advanced raytrace using the parameters previously defined in a T_ADVANCEDRATRACE structure.

 

In the following example, data included in the structure art is used to perform an advanced raytrace. FRED returns the number of rays traced:

 

Dim art As T_ADVANCEDRAYTRACE

InitAdvancedRaytrace art

 :

 :

numTraced = AdvancedRaytrace ( art )


 

"Targeted" raytraces

 

Targeted raytraces take a starting position along with a "hint" and attempt to iterate a ray to a specified end position. The hint can take several forms: position, direction, towards an entity, into an area or solid angle, or into the full 4p steradians. The "TargetedRay" command returns the xyz direction vector of the targeted ray and an indication as to whether the iteration was successful.

 

In this example, user-defined information in the structure tr is used to specify the iteration procedure.

 

Dim tr As T_TARGETEDRAY

Dim x#,y#,z#,valid

InitTargetedRay tr

 :

 :

valid = TargetedRay ( tr, x, y, z )

 

 


See Also….

Basic Raytrace

Coatings

Curves

Elements

Entity Info

General Ray Data

Gratings

Importance Sampling

Linear Transforms

Materials

Ray Buffer Handling

Ray Data Get/Set

Ray Path

Raytrace Control

Scatter

Sources

Surfaces

 

 

 

 

 

Copyright © Photon Engineering, LLC