Description This function sets the configuration parameters for an LED (far-field) type Source Primitive. A boolean is returned indicating whether the parameters were successfully applied.
Syntax success = SourcePrimSetParmLEDff( spNode, tLED, angles(), apods() )
Parameters success (Boolean) Returned boolean indicating whether the parameters were successfully applied to the source node.
spNode As Long Node number of the LED (far-field) type Source Primitive being modified.
tLED as T_SOURCEPRIMLED Data structure containing the configuration parameters of the LED model.
angles() As Double Array of values defining the angles, in degrees, at which the corresponding intensity data is sampled. The intensity data is stored in the apods() array. The apods() array and angles() array must be the same size. See the GetApodData function definition in the example script below, which dimensions and initializes the values in the angles() and apods() arrays.
apods() As Double Array of values defining the relative intensity values of the source emission at the angular sample points given in the angles() array. The apods() array and angles() array must be the same size. See the GetApodData function definition in the example script below, which dimensions and initializes the values in the angles() and apods() arrays.
Example The example below demonstrates how to add an LED (far-field) type Source Primitive node and then configure it using the T_SOURCEPRIMLED data structure parameters. A custom function, GetApodData, is included that populates the arrays storing the angle values and relative intensity apodization values.
Sub Main
Dim spNode As Long Dim spType As String Dim tEnt As T_ENTITY
'String specifying the type of SP being created spType = "LED (far-field)"
'Generic entity information InitEntity( tEnt ) tEnt.name = spType tEnt.Description = "Added via scripting"
'Add the node spNode = AddSourcePrim( spType, tEnt ) Print "Source primitive added at node number " & spNode
'Create intensity apodization data (custom function below) Dim angs() As Double, apods() As Double GetApodData( angs(), apods() )
'Configure parameter settings Dim tLED As T_SOURCEPRIMLEDFF tLED.ApeType = "Rectangle/Square" tLED.NumDirPerRay = 1000 'number of directions per ray position tLED.numRays = 1000 'number of ray positions tLED.power = 100 tLED.PowerUnits = "Lumens" tLED.semiX = 1.0 tLED.semiY = 1.0 SourcePrimSetParmLEDff( spNode, tLED, angs(), apods() )
'Spectrum and wavelength range Dim spectNode As Long, wlMin As Double, wlMax As Double spectNode = SpectrumFindName( "Gaussian" ) wlMin = 0.5 : wlMax = 0.55
'Configure Source Primitive wavelength settings SourcePrimSetWavelSpectValue( spNode, "Random According To Spectrum" ) SetSourceSpectrum( spNode, spectNode ) SetSourceRayWavelengthRange( spNode, wlMin, wlMax )
'Source draw color R=255, G=0, B=0 SourcePrimSetDrawColor( spNode, 255, 0, 0 )
'Update the document Update
End Sub
Function GetApodData( ByRef in_angs() As Double, _ ByRef in_apods() As Double ) As Long
'Helper function for LED (far-field) to generate 'angle and intensity apodization arrays
Erase in_angs Erase in_apods ReDim in_angs(23) ReDim in_apods(23)
in_angs(0) = 0 : in_apods(0) = 0.39 in_angs(1) = 6 : in_apods(1) = 0.39 in_angs(2) = 20 : in_apods(2) = 0.445 in_angs(3) = 30 : in_apods(3) = 0.51 in_angs(4) = 40 : in_apods(4) = 0.63 in_angs(5) = 50 : in_apods(5) = 0.78 in_angs(6) = 56 : in_apods(6) = 0.855 in_angs(7) = 58.6 : in_apods(7) = 0.8976 in_angs(8) = 60.688 : in_apods(8) = 0.947566 in_angs(9) = 63 : in_apods(9) = 0.985 in_angs(10) = 65.3 : in_apods(10) = 1.0 in_angs(11) = 69.58 : in_apods(11) = 0.99 in_angs(12) = 70.3 : in_apods(12) = 0.9538 in_angs(13) = 71.2 : in_apods(13) = 0.891 in_angs(14) = 72.04 : in_apods(14) = 0.808 in_angs(15) = 73.96 : in_apods(15) = 0.6467 in_angs(16) = 75.39 : in_apods(16) = 0.511 in_angs(17) = 76.24 : in_apods(17) = 0.511 in_angs(18) = 78.62 : in_apods(18) = 0.388 in_angs(19) = 81.73 : in_apods(19) = 0.268 in_angs(20) = 86.42 : in_apods(20) = 0.174 in_angs(21) = 87.06 : in_apods(21) = 0.0715 in_angs(22) = 89.8 : in_apods(22) = 0.0136 in_angs(23) = 90 : in_apods(23) = 0.0
Return UBound(in_angs)
End Function
See Also Source Primitive Script Commands
|