Description This command evaluates the diffraction grating function for a specified surface and returns the grating's k-vector in local surface coordinates and the grating function value at the evaluated position. The grating k-vector is normal to the local grating lines and has length equal to the grating frequency. The returned function value indicates the line pair at which the sample point is located.
Syntax GetGratingKVector( gratNode, xPos, yPos, zPos, kA, kB, kC, func )
Parameters gratNode As Long Node number of the grating surface whose grating specification is being queried.
xPos As Double X position of the evaluation point in local surface coordinates.
yPos As Double Y position of the evaluation point in local surface coordinates.
zPos As Double Z position of the evaluation point in local surface coordinates.
kA As Double After the subroutine executes, this parameter contains the X direction cosine of the grating k-vector in local surface coordinates. The value of Sqr(kA2 + kB2 + kC2) is equal to the grating frequency at the evaluation point.
kB As Double After the subroutine executes, this parameter contains the Y direction cosine of the grating k-vector in local surface coordinates. The value of Sqr(kA2 + kB2 + kC2) is equal to the grating frequency at the evaluation point.
kC As Double After the subroutine executes, this parameter contains the Z direction cosine of the grating k-vector in local surface coordinates. The value of Sqr(kA2 + kB2 + kC2) is equal to the grating frequency at the evaluation point.
func As Double After the subroutine executes, this parameter contains the evaluation of the grating function at the point xPos, yPos, zPos. This specifies the grating line pair location of the evaluation point. The function value includes any additional phase offsets specified on the grating surface, so the return value is subject to the "Amount of phase to add per grating line" setting of the grating surface (None, Modulo 2PI, or Continuous with offset).
Example In the following example a linear grating is applied to the surface being queried and the grating lines are aligned to the X-axis with a frequency of 50 lp/mm (one line pair every 0.02 mm). The grating uses the Continuous phase addition per grating line option. When we query the grating, the returned k-vector is (0,50,0) and the function evaluation is 4.5 (i.e. the evaluation point is at 4.5 line pairs along the k-vector direction).
Sub main
'Grating surface Dim grat As Long grat = FindFullName( "Geometry.Elem 1.Surf 2" )
'Distance and angle Dim r As Double, a As Double r = 0.09 a = 0 'degrees
'Convert to x,y and evaluate grating function Dim x As Double, y As Double, z As Double Dim ka As Double, kb As Double, kc As Double, f As Double x = r*Sin(DegToRad(a)) y = r*Cos(DegToRad(a)) z = 0 GetGratingKVector( grat, x, y, z, ka, kb, kc, f )
Print "Position evaluated: " & Chr(9) & x & Chr(9) & y & Chr(9) & z Print "K-Vector:" & Chr(9) & ka & Chr(9) & kb & Chr(9) & kc Print "Grating function: " & Chr(9) & f Print ""
End Sub
See Also Diffraction Grating Script Commands
|