Description This function adds a new position specification for a source with ray direction type, "Multiple source positions". For each specification in the multi-position list, rays will be generated that emit from those positions.
Syntax idx = AddSourceDirIthMultiPos ( src, x, y, z, active )
Parameters idx (Long) Returns the index of the new multi-position specification that was added.
src As Long Node number of the source being modified.
x As Double The X coordinate of the position in the source node coordinate system.
y As Double The Y coordinate of the position in the source node coordinate system.
z As Double The Z coordinate of the position in the source node coordinate system. If z is a positive value, rays will propagate in the -z direction in the source node's coordinate system.
active As Boolean Indicates if the multi-position specification is active. When active, rays will be created coming from this point. When inactive, no rays will be created coming from this point.
Example The example below shows how to replace the existing list of multi-position specifications in a source node with a rectilinear grid of new positions.
Sub Main
'Source node being modified Dim src As Long src = FindFullName( "Optical Sources.Multi Pos Source" )
'Grid of positions we want to create Dim xMin As Double, xMax As Double Dim yMin As Double, yMax As Double Dim nX As Long, nY As Long xMin = -4 : xMax = 4 yMin = -4 : yMax = 4 nX = 3 nY = 3
'Derive position steps Dim xStep As Double, yStep As Double xStep = (xMax - xMin)/(nX-1) yStep = (yMax - yMin)/(nY-1)
'Delete existing positions Dim curPos As Long, nPos As Long nPos = GetSourceDirMultiPosCount( src ) For curPos = nPos-1 To 0 Step -1 DeleteSourceDirIthMultiPos( src, curPos ) Next
'Print Header row Print "" Print "Entry" & Chr(9) & "X (mm)" & Chr(9) & "Y (mm)"
'Add new position(s) 'Ray directions are set as though they are coming FROM the points added below Dim curX As Long, curY As Long, ithPos As Long Dim xPos As Double, yPos As Double For curX = 0 To nX-1 For curY = 0 To nY-1 xPos = xMin + xStep*curX yPos = yMin + yStep*curY ithPos = AddSourceDirIthMultiPos( src, xPos, yPos, -10.0, True ) Print ithPos; Print xPos; Print yPos Next Next
Update
End Sub
See Also
|