protected override void AfterCircle(IExportClient cl)
        {
            for (int j = 0; j < N; ++j)
            {
                var angle = j * 360 / N * Deg2Rad;

                cl.Circle(new SolverPoint(Rz * Math.Cos(angle), Rz * Math.Sin(angle)), q, 1, "output_rollers");
            }
        }
        protected override SolverPoint GetCircularPoint(int step, double angleRads, IExportClient cl)
        {
            var v = (A - B) / B * angleRads;

            var centerX = (A - B) * Math.Cos(angleRads);
            var centerY = (A - B) * Math.Sin(angleRads);
            var x       = centerX + B * Math.Cos(v);
            var y       = centerY - B * Math.Sin(v);

            var result = new SolverPoint(x, y);


            if (step % (NumSteps / 20) == 0)
            {
                cl.Circle(new SolverPoint(centerX, centerY), B, 1, "circles");
                cl.Point(result, 5, "points");
            }


            return(result);
        }
Example #3
0
        protected override void AfterCircle(IExportClient cl)
        {
            // Tolerances

            var dgap     = deo + dR + dcs + dcp;
            var Rprofile = R - dgap;

            var dsum     = Math.Sqrt(deo * deo + dR * dR + dcs * dcs + dcp * dcp + djb * djb) + dgap;
            var backlash = 2 * dsum / (E * Z1);  // radians

            // Rollers after tolerance

            for (int i = 0; i < Z1 + 1; ++i)
            {
                var angle = 360d / (Z1 + 1) * i * Deg2Rad;

                var x = Rprofile * Math.Cos(angle) - E;
                var y = Rprofile * Math.Sin(angle);

                cl.Circle(new SolverPoint(x, y), Rr, 4, "rollers_tolerance");
            }
        }
Example #4
0
        protected override void BeforeCircle(IExportClient cl)
        {
            // Constraints


            // R constraint

            var Rmin = Math.Sqrt(
                (Rr * Rr * Math.Pow(Z1 + 2, 3)) /
                (27 * Z1)
                + E * E * Math.Pow(Z1 + 1, 2));

            if (R < Rmin)
            {
                R = Rmin;
                mParams[0].Value = R;
            }


            // Rr constraint

            var Rrmax1 = R * Math.Sin(Math.PI / (Z1 + 1));
            var Rrmax2 = Math.Sqrt(
                (27 * Z1 * (R * R - E * E * (Z1 + 1) * (Z1 + 1))) /
                Math.Pow(Z1 + 2, 3));

            var Rrmax = Math.Min(Rrmax1, Rrmax2);

            if (Rr > Rrmax)
            {
                Rr = Rrmax;
                mParams[1].Value = Rr;
            }


            // Eccentricity constraint

            var Emax = Math.Sqrt(
                (27 * R * R * Z1 - Rr * Rr * Math.Pow(Z1 + 2, 3)) /
                (27 * Z1 * Math.Pow(Z1 + 1, 2)));

            if (E > Emax)
            {
                E = Emax;
                mParams[3].Value = E;
            }


            // Draw Rollers

            for (int i = 0; i < Z1 + 1; ++i)
            {
                var angle = 360d / (Z1 + 1) * i * Deg2Rad;

                var x = R * Math.Cos(angle) - E;
                var y = R * Math.Sin(angle);

                cl.Circle(new SolverPoint(x, y), Rr, 1, "rollers");
            }

            // Draw Centers

            cl.Circle(new SolverPoint(-E, 0), 2.5, 1, "rollers");
            cl.Circle(new SolverPoint(0, 0), CamDiameter / 2, 0, "base");
        }
 protected override void AfterCircle(IExportClient cl)
 {
     cl.Circle(new SolverPoint(0, 0), A, 1, "circles");
 }
Example #6
0
        public void Run(IExportClient cl)
        {
            if (cl == null)
            {
                throw new Exception("null export client");
            }

            //if b > 0:
            //    p = b/n
            if (b > 0)
            {
                p = b / n;
            }

            //q=2*math.pi/float(s)
            var q = 2.0 * Math.PI / s;

            //# Find the pressure angle limit circles
            //minAngle = -1.0
            //maxAngle = -1.0
            //for i in range(0, 180):
            //        x = calcPressureAngle(p,d,n,float(i)*math.pi/180)
            //        if (x < ang) and (minAngle < 0):
            //                minAngle = float(i)
            //        if (x < -ang) and (maxAngle < 0):
            //                maxAngle = float(i-1)
            //minRadius = calcPressureLimit(p,d,e,n,minAngle*math.pi/180)
            //maxRadius = calcPressureLimit(p,d,e,n,maxAngle*math.pi/180)
            //dxf.append( sdxf.Circle(center=(-e, 0), radius=minRadius, layer="pressure") )
            //dxf.append( sdxf.Circle(center=(-e, 0), radius=maxRadius, layer="pressure") )

            var minAngle = -1.0;
            var maxAngle = -1.0;

            for (int i = 0; i < 180; ++i)
            {
                var x = CalcPressureAngle(p, d, n, i * Math.PI / 180d);
                if (x < ang && minAngle < 0)
                {
                    minAngle = (double)i;
                }
                if (x < -ang && maxAngle < 0)
                {
                    maxAngle = (double)(i - 1);
                }
            }

            var minRadius = CalcPressureLimit(p, d, e, n, minAngle * Math.PI / 180d);
            var maxRadius = CalcPressureLimit(p, d, e, n, maxAngle * Math.PI / 180d);

            cl.Circle(new SolverPoint(-e, 0), minRadius, 2, "pressure");
            cl.Circle(new SolverPoint(-e, 0), maxRadius, 2, "pressure");


            //#generate the cam profile - note: shifted in -x by eccentricicy amount
            //i=0
            //x1 = calcX(p,d,e,n,q*i)
            //y1 = calcY(p,d,e,n,q*i)
            //x1, y1 = checkLimit(x1,y1,maxRadius, minRadius, c)
            //for i in range(0, s):
            //        x2 = calcX(p,d,e,n,q*(i+1))
            //        y2 = calcY(p,d,e,n,q*(i+1))
            //        x2, y2 = checkLimit(x2,y2,maxRadius, minRadius, c)
            //    dxf.append( sdxf.Line(points=[(x1-e,y1),  (x2-e,y2)], layer="cam" ) )
            //        x1 = x2
            //        y1 = y2
            var points = new List <SolverPoint>();

            var ii  = 0;
            var x1  = CalcX(p, d, e, n, q * ii);
            var y1  = CalcY(p, d, e, n, q * ii);
            var xy1 = CheckLimit(x1, y1, maxRadius, minRadius, c);

            xy1.X -= e;
            points.Add(xy1);

            for (int j = 0; j < s; ++j)
            {
                var x2  = CalcX(p, d, e, n, q * (j + 1));
                var y2  = CalcY(p, d, e, n, q * (j + 1));
                var xy2 = CheckLimit(x2, y2, maxRadius, minRadius, c);

                xy2.X -= e;
                points.Add(xy2);
            }

            cl.Spline(points, 0, "cam");



            //#add a circle in the center of the cam
            //dxf.append( sdxf.Circle(center=(-e, 0), radius=d/2, layer="cam") )

            cl.Circle(new SolverPoint(-e, 0), ccd / 2, 0, "cam");

            //#generate the pin locations
            //for i in range(0, n+1):
            //    x = p*n*math.cos(2*math.pi/(n+1)*i)
            //    y = p*n*math.sin(2*math.pi/(n+1)*i)
            //    dxf.append( sdxf.Circle(center=(x,y), radius=d/2, layer="roller") )
            //#add a circle in the center of the pins
            //dxf.append( sdxf.Circle(center=(0, 0), radius=d/2, layer="roller") )
            for (int k = 0; k < n + 1; ++k)
            {
                var x = p * n * Math.Cos(2 * Math.PI / (n + 1) * k);
                var y = p * n * Math.Sin(2 * Math.PI / (n + 1) * k);
                cl.Circle(new SolverPoint(x, y), d / 2, 1, "roller");
            }

            cl.Circle(new SolverPoint(0, 0), csd / 2, 1, "roller");
        }