Beispiel #1
0
        private SvgPath CreateSlotPath()
        {
            var endCapRadius   = FastenerDiameter / 2f - Constants.Kerf;
            var innerArcRadius = Constants.JigHoleSpacing - (FastenerDiameter / 2f - Constants.Kerf);

            float innerArcX = innerArcRadius * DegreeTrig.Cos(startAngle);
            float innerArcY = -innerArcRadius *DegreeTrig.Sin(startAngle);  // y's are negative b/c they are above the origin hole

            float outerArcX = outerArcRadius * DegreeTrig.Cos(startAngle);
            float outerArcY = -outerArcRadius *DegreeTrig.Sin(startAngle);

            var pointA = Points.MetricPoint(-outerArcX, outerArcY);
            var pointB = Points.MetricPoint(outerArcX, outerArcY);
            var pointC = Points.MetricPoint(innerArcX, innerArcY);
            var pointD = Points.MetricPoint(-innerArcX, innerArcY);

            var slotPath = Paths.CutPath();

            var leftEndCap  = MakeEndCap(-innerArcX, innerArcY, -outerArcX, outerArcY);
            var rightEndCap = MakeEndCap(outerArcX, outerArcY, innerArcX, innerArcY);

            slotPath.PathData.Add(new SvgMoveToSegment(pointA));
            slotPath.PathData.Add(Arcs.SimpleSegment(pointA, outerArcRadius, SvgArcSweep.Positive, pointB));
            slotPath.PathData.Add(Arcs.SimpleSegment(pointB, endCapRadius, SvgArcSweep.Positive, pointC));
            slotPath.PathData.Add(Arcs.SimpleSegment(pointC, innerArcRadius, SvgArcSweep.Negative, pointD)); // Negative makes the lower arc path back "into" the body of the shape
            slotPath.PathData.Add(Arcs.SimpleSegment(pointD, endCapRadius, SvgArcSweep.Positive, pointA));
            return(slotPath);
        }
Beispiel #2
0
        private SvgGroup CreateAngleText()
        {
            var group = new SvgGroup();

            var majorAngleIncrement = (float)totalProtractorAngleSweep / majorDivisions;

            for (int i = 0; i <= majorDivisions; i++)
            {
                // The angle from the horizontal, used for positioning each label
                var a = startAngle + i * majorAngleIncrement;

                // this is the angle from the vertical.  The graduation mark function uses the angle from the horizontal.
                // the letters start rotated left -60
                var textRotation = -90 + a;

                // go from -n to n
                var number = -totalProtractorAngleSweep / 2 + i * majorAngleIncrement;

                var   label = Text.EtchedText(number.ToString("#0"), textHeight);
                float x     = -textBaselineRadius *DegreeTrig.Cos(a);

                float y = -textBaselineRadius *DegreeTrig.Sin(a);

                label.Transforms.Add(new SvgTranslate(x.Px(), y.Px()));
                label.Transforms.Add(new SvgRotate(textRotation));

                group.Children.Add(label);
            }

            return(group);
        }
Beispiel #3
0
        public override void Create()
        {
            const float jigTopRadius = Constants.JigHoleSpacing + widthAboveRadiusHoles;
            const float cornerRadius = 3f;

            CreateRadiusHoles(out float pivotY); // pivotY is ~26mm

            Children.Add(Lines.EtchLine(0, -widthAboveRadiusHoles, 0, -(widthAboveRadiusHoles - guideLineLength)));

            var path = Paths.CutPath();

            var   pointA          = Points.MetricPoint(0, Constants.JigHoleSpacing + pivotY);
            float pointerCornersY = Constants.JigHoleSpacing + pivotY - rightSideWidth;
            var   pointB          = Points.MetricPoint(rightSideWidth, pointerCornersY);

            const float jigSweep  = 45f; // degrees of sweep the jig body will have
            var         angleBeta = Math.PI / 180f * (90 - jigSweep / 2);
            var         angleP    = Math.Acos(rightSideWidth / jigTopRadius) - angleBeta;
            var         n         = jigTopRadius * DegreeTrig.Sin(jigSweep / 2);

            var d = 2 * n * Math.Sin(angleP);
            var c = 2 * n * Math.Cos(angleP);

            var cY     = Constants.JigHoleSpacing - Math.Sqrt(Math.Pow(jigTopRadius, 2) - Math.Pow(rightSideWidth, 2));
            var pointC = Points.MetricPoint(rightSideWidth, (float)cY);

            var dX = -(c - rightSideWidth);
            var dY = cY + d;

            var pointD = Points.MetricPoint((float)dX, (float)dY);

            var pointE = Points.MetricPoint(-rightSideWidth, pointerCornersY);

            path.PathData.Add(new SvgMoveToSegment(pointA));
            path.PathData.Add(new SvgLineSegment(pointA, pointB));
            path.PathData.Add(new SvgLineSegment(pointB, pointC));
            path.PathData.Add(Arcs.SimpleSegment(pointC, jigTopRadius, SvgArcSweep.Negative, pointD));
            path.PathData.Add(new SvgLineSegment(pointD, pointE));
            path.PathData.Add(new SvgLineSegment(pointE, pointA));

            Children.Add(path);
        }
Beispiel #4
0
        private SvgGroup CreateAngleMarks()
        {
            var group          = new SvgGroup();
            var minorIncrement = (float)totalProtractorAngleSweep / (minorDivisions * majorDivisions);
            var doMidPoint     = minorDivisions % 2 == 0;

            // Spin through the minor divisions selecting the length of the line as we go
            for (int i = 0; i <= majorDivisions * minorDivisions; ++i)
            {
                var   a = startAngle + i * minorIncrement;
                float lineLength;

                if (i % minorDivisions == 0)          // 0, 10, 20 should draw major lines
                {
                    lineLength = majorDivisionLength; // major
                }
                else if (doMidPoint && i % (minorDivisions / 2) == 0)
                {
                    lineLength = minorDivisionLength + 1.5f; // midpoint
                }
                else
                {
                    lineLength = minorDivisionLength;
                }

                var l = Lines.EtchLine(
                    // all lines start on the edge and continue along their length
                    -bodyRadius * DegreeTrig.Cos(a),
                    -bodyRadius * DegreeTrig.Sin(a),
                    -(bodyRadius - lineLength) * DegreeTrig.Cos(a),
                    -(bodyRadius - lineLength) * DegreeTrig.Sin(a));

                group.Children.Add(l);
            }

            return(group);
        }
Beispiel #5
0
        private void CreateRadiusHoles(out float pivotY)
        {
            // top hole is the origin point
            // pivot point Y is the bottom  hole
            // The tip of the jig is pivotY beyond the bottom hole

            var topHole = Circles.CutCircle(FastenerDiameter, 0, 0);

            var          smallestRadius         = radii.Min();
            const double originToSmallestLength = 50;
            var          angleAlpha             = Math.Asin(originToSmallestLength / (2 * smallestRadius)) * 2; // radians
            var          angleBeta = Math.PI / 2 - angleAlpha;
            var          h         = smallestRadius / Math.Cos(angleAlpha);
            var          x         = h - smallestRadius;

            pivotY = (float)(x * Math.Tan(angleBeta));

            var bottomHole = topHole.CreateReference(0, Constants.JigHoleSpacing);

            foreach (var radius in radii)
            {
                var d      = Math.Sqrt(Math.Pow(pivotY, 2) + Math.Pow(radius, 2));
                var angleC = Math.Asin(radius / d);
                var angleR = Math.PI - 2 * angleC;

                Debug.WriteLine($"r: {DegreeTrig.Degrees(angleR)}");

                // Finally we can make a stupid circle.  Start it at 0,0 and rotate it R around the pivot-Y point.
                var hole = Circles.CutCircle(FastenerDiameter, 0, 0);
                hole.Transforms.Add(new SvgRotate(DegreeTrig.Degrees(-angleR), 0, Constants.JigHoleSpacing.Px()));

                Children.Add(hole);
            }
            Children.Add(topHole);
            Children.Add(bottomHole);
        }