/** * Set up the data object with empty UltrasoundPoint%s representing the points * that need to be scanned. * * This is analagous to setting up the view frustum in traditional 3D graphics. */ private void EstablishScanningPlane(ref UltrasoundScanData data) { OnionLogger.globalLog.PushInfoLayer("Pre-populating data"); UltrasoundProbeConfiguration config = data.GetProbeConfig(); // nearZ and farZ represent near and far clipping "planes" (they're really arcs) float nearZ = config.GetMinScanDistance(); float farZ = config.GetMaxScanDistance(); float arcSizeDegrees = config.GetArcSizeInDegrees(); int scanlines = config.GetNumberOfScanlines(); int pointsPerScanline = config.GetPointsPerScanline(); for (int i = 0; i < scanlines; ++i) { UltrasoundScanline scanline = new UltrasoundScanline(config.GetPosition()); float angleInDegrees = -(arcSizeDegrees / 2) + i * arcSizeDegrees / (scanlines - 1); float angleInRadians = Mathf.Deg2Rad * angleInDegrees; Vector2 trajectory = new Vector2(Mathf.Sin(angleInRadians), Mathf.Cos(angleInRadians)); for (int j = 0; j < pointsPerScanline; ++j) { float d = nearZ + j * (farZ - nearZ) / (pointsPerScanline - 1); Vector2 positionOnPlane = d * trajectory; Vector3 positionInWorldSpace = WorldSpaceFromProjectedPosition(positionOnPlane, config); UltrasoundPoint point = new UltrasoundPoint(positionInWorldSpace, positionOnPlane); scanline.AddUltrasoundPoint(point); } data.AddScanline(scanline); } OnionLogger.globalLog.PopInfoLayer(); }
/** * Copy constructor to instantiate a new UltrasoundProbeConfiguration from another. * * @param config The other UltrasoundProbeConfiguration object. * @throw ArgumentNullException */ public UltrasoundProbeConfiguration(UltrasoundProbeConfiguration config) { UltrasoundDebug.Assert(null != config, "Null UltrasoundProbeConfiguration used for copy constructor.", this); this.SetPosition(config.GetPosition()); this.SetRotation(config.GetRotation()); this.maxDistance = config.GetMaxScanDistance(); this.minDistance = config.GetMinScanDistance(); this.arcSizeInDegrees = config.GetArcSizeInDegrees(); this.pointsPerScanline = config.GetPointsPerScanline(); this.numberOfScanlines = config.GetNumberOfScanlines(); this.gain = config.GetGain(); }