private static Geometry CreateGeometryPre909(GunVerticalTraverseComponentViewModel traverse, Point center, Func <double, double> radiusConverter, double geometryRotation = 0) { Geometry geometry; double maxRadius; if (traverse.HasSingularValue && traverse.HorizontalTraverse.Range == 360) { var radius = radiusConverter(traverse.Default); geometry = new EllipseGeometry(center, radius, radius); maxRadius = radius; } else { var leftRadius = radiusConverter(traverse.Left); var rightRadius = radiusConverter(traverse.Right); var frontRadius = radiusConverter(traverse.Front); var backRadius = radiusConverter(traverse.Back); maxRadius = MathEx.Max(leftRadius, rightRadius, frontRadius, backRadius); var figureFigure = new PathFigure(); double theta; Point point; double arcRange; if (traverse.HasExtraFrontPitchLimits) { // in standard polar coordinate system theta = geometryRotation - traverse.ExtraFrontPitchLimitsRange / 2 - traverse.ExtraPitchLimitsTransition; point = GunTraverseHelper.PolarToCartesian(center, rightRadius, theta); figureFigure.StartPoint = point; // right to front transition point = GunTraverseHelper.PolarToCartesian(center, frontRadius, theta); if (traverse.ExtraPitchLimitsTransition == 0) { figureFigure.Segments.Add(new LineSegment(point, true)); } else { figureFigure.Segments.Add(GunTraverseHelper.CreateTraverseFigureTransition(ref figureFigure, ref center, theta, traverse.ExtraPitchLimitsTransition, rightRadius, frontRadius)); } // front theta = geometryRotation + traverse.ExtraFrontPitchLimitsRange / 2; point = GunTraverseHelper.PolarToCartesian(center, frontRadius, theta); arcRange = traverse.ExtraFrontPitchLimitsRange; var frontArc = new ArcSegment(point, new Size(frontRadius, frontRadius), arcRange, arcRange >= 180, SweepDirection.Counterclockwise, true); figureFigure.Segments.Add(frontArc); // front to left transition point = GunTraverseHelper.PolarToCartesian(center, leftRadius, theta); if (traverse.ExtraPitchLimitsTransition == 0) { figureFigure.Segments.Add(new LineSegment(point, true)); } else { figureFigure.Segments.Add(GunTraverseHelper.CreateTraverseFigureTransition(ref figureFigure, ref center, theta, traverse.ExtraPitchLimitsTransition, frontRadius, leftRadius)); } } else { theta = geometryRotation; point = GunTraverseHelper.PolarToCartesian(center, leftRadius, theta); figureFigure.StartPoint = point; } // left var leftArcEndAngle = traverse.HasExtraBackPitchLimits ? 180 + geometryRotation - traverse.ExtraBackPitchLimitsRange / 2 - traverse.ExtraPitchLimitsTransition : 180 + geometryRotation; point = GunTraverseHelper.PolarToCartesian(center, leftRadius, leftArcEndAngle); arcRange = leftArcEndAngle - theta; var leftArc = new ArcSegment(point, new Size(leftRadius, leftRadius), arcRange, arcRange >= 180, SweepDirection.Counterclockwise, true); figureFigure.Segments.Add(leftArc); if (traverse.HasExtraBackPitchLimits) { // left to back transition theta = leftArcEndAngle; point = GunTraverseHelper.PolarToCartesian(center, backRadius, theta); if (traverse.ExtraPitchLimitsTransition == 0) { figureFigure.Segments.Add(new LineSegment(point, true)); } else { figureFigure.Segments.Add(GunTraverseHelper.CreateTraverseFigureTransition(ref figureFigure, ref center, theta, traverse.ExtraPitchLimitsTransition, leftRadius, backRadius)); } // back theta = 180 + geometryRotation + traverse.ExtraBackPitchLimitsRange / 2; point = GunTraverseHelper.PolarToCartesian(center, backRadius, theta); arcRange = traverse.ExtraBackPitchLimitsRange; var backArc = new ArcSegment(point, new Size(backRadius, backRadius), arcRange, arcRange >= 180, SweepDirection.Counterclockwise, true); figureFigure.Segments.Add(backArc); // back to right transition point = GunTraverseHelper.PolarToCartesian(center, rightRadius, theta); if (traverse.ExtraPitchLimitsTransition == 0) { figureFigure.Segments.Add(new LineSegment(point, true)); } else { figureFigure.Segments.Add(GunTraverseHelper.CreateTraverseFigureTransition(ref figureFigure, ref center, theta, traverse.ExtraPitchLimitsTransition, backRadius, rightRadius)); } } // right var rightArcEndAngle = traverse.HasExtraFrontPitchLimits ? 360 + geometryRotation - traverse.ExtraFrontPitchLimitsRange / 2 - traverse.ExtraPitchLimitsTransition : 360 + geometryRotation; point = GunTraverseHelper.PolarToCartesian(center, rightRadius, rightArcEndAngle); arcRange = theta - rightArcEndAngle; var rightArc = new ArcSegment(point, new Size(rightRadius, rightRadius), arcRange, arcRange >= 180, SweepDirection.Counterclockwise, true); figureFigure.Segments.Add(rightArc); var pathGeometry = new PathGeometry(); pathGeometry.Figures.Add(figureFigure); geometry = pathGeometry; } return(GunTraverseHelper.ProcessGeometryHorizontalTraverse(traverse, center, geometryRotation, geometry, maxRadius)); }
private static Geometry CreateGeometryPost909(GunVerticalTraverseComponentViewModel traverse, Point center, Func <double, double> radiusConverter, double geometryRotation = 0) { Geometry geometry; double maxRadius; var data = traverse.TraverseData; if (data.Length == 1 || (data.Length == 2 && data[0].Limit == data[1].Limit)) { var radius = radiusConverter(data[0].Limit); geometry = new EllipseGeometry(center, radius, radius); maxRadius = radius; } else { maxRadius = radiusConverter(traverse.MaximumTraverse); var figureFigure = new PathFigure(); var previousTheta = 0.0; var previousPoint = new Point(); var previousRadius = 0.0; PitchLimits.Component previousNode = new PitchLimits.Component(); for (var i = 0; i < data.Length; ++i) { var node = data[i]; var theta = geometryRotation + node.Angle * 360; var radius = radiusConverter(node.Limit); var point = GunTraverseHelper.PolarToCartesian(center, radius, theta); var thetaRange = theta - previousTheta; if (i == 0) { figureFigure.StartPoint = point; } else { if (previousNode.Angle == node.Angle) { figureFigure.Segments.Add(new LineSegment(point, true)); } else if (previousNode.Limit == node.Limit) { figureFigure.Segments.Add(new ArcSegment(point, new Size(radius, radius), thetaRange, thetaRange >= 180, SweepDirection.Counterclockwise, true)); } else { figureFigure.Segments.Add(GunTraverseHelper.CreateTraverseFigureTransition(ref figureFigure, ref center, previousTheta, thetaRange, previousRadius, radius)); } } previousTheta = theta; previousPoint = point; previousNode = node; previousRadius = radius; } var pathGeometry = new PathGeometry(); pathGeometry.Figures.Add(figureFigure); geometry = pathGeometry; } return(GunTraverseHelper.ProcessGeometryHorizontalTraverse(traverse, center, geometryRotation, geometry, maxRadius)); }