IRayTraceNSCData

在非序列模式下,有一种追迹模式IRayTraceNSCData。

打开工具时,用户选择要追迹的最大光线数、每条单独光线的最大区段数以及相干长度。

CreateNSC (int MaxRays, int maxSegments, double coherenceLength)

然后在AddRay函数中逐个定义光线。

AddRay (int waveNumber, int surf, NSCTraceOptions mode, double X, double Y, double Z, double L, double M, double N, int InsideOf, double exr, double exi, double eyr, double eyi, double ezr, double ezi)

光线的定义如下:

  • int waveNumber:与波数相关的波长
  • int surf:开始光线追迹的表面
  • NSCTraceOptions:用于追踪光线的非序列模式选项。有8个选项。添加了最后4个选项,因为Matlab/Python不能正确支持.NET枚举。对于C#和C++,可使用位OR运算符组合前4个选项:
    • UsePolarization
    • UseSplitting
    • UseScattering
    • UsePolarizationSplitting
    • UsePolarizationScattering
    • UseSplittingScattering
    • UsePolarizationSplittingScattering
  • double X、Y、Z:光线在起始表面上的坐标
  • double L、M、N:光线在起始表面上的方向余弦
  • int InsideOf:表示起始表面是否在对象内部。如果在空气中,InsideOf=0,否则等于它在其中的对象。
  • double exr、exi、eyr、eyi、ezr、ezi:光线在起始表面上的电性

请注意,输入强度始终假定为等于1.0。因此,电场幅值(若使用)也应该为1.0。

如果在光线追迹中使用偏振(NSCTraceOptions=UsePolarization),则必须提供初始电场值。用户应用程序必须确保定义的矢量与光线传播矢量正交,并且生成的强度与起始强度值匹配,否则将生成错误的光线追迹结果。

结果

有两种方法可以返回结果:一种是逐条光线读取,另一种是逐条分段读取:

ReadNextResult (out int rayNumber, out int ErrorCode, out int wave, out int numSegments)
 
ReadNextSegment (out int segmentLevel, out int segmentParent, out int hitObj, out int InsideOf, out double X, out double Y, out double Z, out double L, out double M, out double N, out double exr, out double exi, out double eyr, out double eyi, out double ezr, out double ezi, out double intensity, out double pathLength)
  • rayNumber
  • ErrorCode
  • wave
  • numSegments:光线的区段数
  • segmentLevel
  • segmentParent
  • hitObj
  • InsideOf
  • double X, out double Y, out double Z
  • double L, out double M, out double N
  • double exr, out double exi, out double eyr, out double eyi, out double ezr, out double ezi
  • 强度:光线的相对透射强度
  • double intensity
  • double pathLength:以镜头单位为单位的物理长度,不是光程

下一部分: