Beispiel #1
0
        private void InsertToothPath(Pinion pinion, PinionTooth tooth, PinionTooth nextTooth, StringBuilder pathBuilder)
        {
            pathBuilder.AppendFormat(CultureInfo.InvariantCulture, " L{0},{1}", (float)tooth.PitchCircleIntersectLeft.X, (float)tooth.PitchCircleIntersectLeft.Y);

            pathBuilder.AppendFormat(
                CultureInfo.InvariantCulture,
                " A{0},{1} 0 0,1 {2},{3}",
                (float)pinion.AddendumRadius, (float)pinion.AddendumRadius,
                (float)tooth.Apex.X, (float)tooth.Apex.Y);

            pathBuilder.AppendFormat(
                CultureInfo.InvariantCulture,
                " A{0},{1} 0 0,1 {2},{3}",
                (float)pinion.AddendumRadius, (float)pinion.AddendumRadius,
                (float)tooth.PitchCircleIntersectRight.X, (float)tooth.PitchCircleIntersectRight.Y);

            pathBuilder.AppendFormat(CultureInfo.InvariantCulture, " L{0},{1}", (float)tooth.DedendumIntersectRight.X, (float)tooth.DedendumIntersectRight.Y);

            double radius = pinion.PitchDiameter / 2.0 - pinion.Dedendum;

            pathBuilder.AppendFormat(
                CultureInfo.InvariantCulture,
                " A{0},{1} 0 0,1 {2},{3}",
                (float)radius, (float)radius,
                (float)nextTooth.DedendumIntersectLeft.X, (float)nextTooth.DedendumIntersectLeft.Y);
        }
Beispiel #2
0
        internal void Build(Pinion pinion, SvgSvgElement root)
        {
            SvgGroupElement helperLinesGroup = new SvgGroupElement("HelperLines");

            helperLinesGroup.Style = Styles.HelperLineStyle;
            root.AddChild(helperLinesGroup);

            // Wheel pitch circle
            helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0));

            // Wheel addendum circle
            helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0 + pinion.Addendum));

            // Wheel dedendum circle
            helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0 - pinion.Dedendum));

            // wheel center
            double halfCrossLength = 10;

            helperLinesGroup.AddChild(new SvgLineElement(pinion.Center.X - halfCrossLength, pinion.Center.Y, pinion.Center.X + halfCrossLength, pinion.Center.Y));
            helperLinesGroup.AddChild(new SvgLineElement(pinion.Center.X, pinion.Center.Y - halfCrossLength, pinion.Center.X, pinion.Center.Y + halfCrossLength));

            SvgGroupElement mainGroup = new SvgGroupElement("Main");

            mainGroup.Style = Styles.MinorLineStyle;
            root.AddChild(mainGroup);


            PinionTooth[] teeth       = pinion.GetTeeth(Math.PI / pinion.ToothCount);
            StringBuilder pathBuilder = new StringBuilder();

            pathBuilder.AppendFormat(CultureInfo.InvariantCulture, "M{0},{1}", (float)teeth[0].DedendumIntersectLeft.X, (float)teeth[0].DedendumIntersectLeft.Y);
            for (int i = 0; i < teeth.Length; i++)
            {
                PinionTooth tooth     = teeth[i];
                PinionTooth nextTooth = teeth[(i + 1) % teeth.Length];
                InsertToothPath(pinion, tooth, nextTooth, pathBuilder);
            }
            pathBuilder.Append(" z");


            SvgPath        svgPath        = new SvgPath(pathBuilder.ToString());
            SvgPathElement svgPathElement = new SvgPathElement();

            svgPathElement.D = svgPath;

            mainGroup.AddChild(svgPathElement);

            if (pinion.CenterHoleDiameter > 0)
            {
                mainGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.CenterHoleDiameter / 2.0));
            }
        }
        private void InsertToothPath(Pinion pinion, PinionTooth tooth, PinionTooth nextTooth, StringBuilder pathBuilder)
        {
            pathBuilder.AppendFormat(CultureInfo.InvariantCulture, " L{0},{1}", (float)tooth.PitchCircleIntersectLeft.X, (float)tooth.PitchCircleIntersectLeft.Y);

            pathBuilder.AppendFormat(
                CultureInfo.InvariantCulture,
                " A{0},{1} 0 0,1 {2},{3}",
                (float)pinion.AddendumRadius, (float)pinion.AddendumRadius,
                (float)tooth.Apex.X, (float)tooth.Apex.Y);

            pathBuilder.AppendFormat(
                CultureInfo.InvariantCulture,
                " A{0},{1} 0 0,1 {2},{3}",
                (float)pinion.AddendumRadius, (float)pinion.AddendumRadius,
                (float)tooth.PitchCircleIntersectRight.X, (float)tooth.PitchCircleIntersectRight.Y);

            pathBuilder.AppendFormat(CultureInfo.InvariantCulture, " L{0},{1}", (float)tooth.DedendumIntersectRight.X, (float)tooth.DedendumIntersectRight.Y);

            double radius = pinion.PitchDiameter / 2.0 - pinion.Dedendum;
            pathBuilder.AppendFormat(
                CultureInfo.InvariantCulture,
                " A{0},{1} 0 0,1 {2},{3}",
                (float)radius, (float)radius,
                (float)nextTooth.DedendumIntersectLeft.X, (float)nextTooth.DedendumIntersectLeft.Y);
        }