Exemple #1
0
        public void compute()
        {
            double prevLift = 0;
            double prevVelocity = 0;
            double timePerStep = 60.0 / Data.iRpm / 360.0 * STEPSIZE;

            CompGeometry cg = new CompGeometry();

            for (double alpha = Constants.R90; alpha >= 0; alpha -= Change.toRadians(STEPSIZE) )
            {
                Coord contact = cg.compLifterLift(alpha);

                // Half width of lifter
                if(contact.x > maxLifter) { maxLifter = contact.x; }

                // Lift
                double lift = contact.y; // -Data.dBaseRadius;
                pLift.Add(new Polar(lift, alpha));
                if(lift > maxLift.r) { maxLift = new Polar(lift, alpha); }
                if(lift < minLift.r) { minLift = new Polar(lift, alpha); }

                // Vertical velocity
                double velocity = (lift - prevLift) / timePerStep;
                pVelocity.Add(new Polar(velocity, alpha));
                if(velocity > maxVelocity.r) { maxVelocity = new Polar(velocity, alpha); }
                if(velocity < minVelocity.r) { minVelocity = new Polar(velocity, alpha); }

                // Vertical acceleration
                double acceleration = velocity - prevVelocity;
                pAcceleration.Add(new Polar(acceleration, alpha));
                if(acceleration > maxAcceleration.r) { maxAcceleration = new Polar(acceleration, alpha); }
                if(acceleration < minAcceleration.r) { minAcceleration = new Polar(acceleration, alpha); }

                // Save for previuos compares
                prevLift = lift;
                prevVelocity = velocity;

                // For testing
                double a = Change.toDegrees(alpha);
                double xx = contact.x;
                double yy = contact.y;
            }

            Data.dLifterDiameter = maxLifter * 2;

            // For testing
            //double l1 = maxLift.aDeg;
            //double l2 = maxLift.r;
            //double v1 = maxVelocity.aDeg;
            //double v2 = maxVelocity.r;
            //double v3 = minVelocity.aDeg;
            //double v4 = minVelocity.r;
            //double a1 = maxAcceleration.aDe
            //double a2 = maxAcceleration.r;
            //double a3 = minAcceleration.aDeg;
            //double a4 = minAcceleration.r;
        }
Exemple #2
0
        // This just builds the raw offsets for a particular resolution in degrees
        public static List<Polar> buildRawOffsets(double resolution, double wheelDiameter)
        {
            List<Polar> offsets = new List<Polar>();

            CompGeometry cg = new CompGeometry();
            for (double alpha = 0; alpha < Constants.R360; alpha += Change.toRadians(resolution))
            {
                double a = Change.toDegrees(alpha);
                double offset = cg.compGrinderOffset(alpha);
                offsets.Add(new Polar(offset, alpha));
            }

            return offsets;
        }
Exemple #3
0
        public void drawGrinder(double alpha)
        {
            double offset;
            float wheelCentreX;
            float wheelCentreY;

            CompGeometry cg = new CompGeometry();
            offset = cg.compGrinderOffset(Change.toRadians(alpha));
            wheelCentreX = (float)(offset * Math.Sin(Change.toRadians(alpha)));
            wheelCentreY = (float)(offset * Math.Cos(Change.toRadians(alpha)));

            //wheelCentreX = 0;
            //wheelCentreY = (float)offset;

            g.drawLine(grinderPen, 0, 0, wheelCentreX, wheelCentreY);
            g.drawArc(grinderPen, wheelCentreX, wheelCentreY, Data.dWheelDiameter / 2, 0, 360);

            //g.drawLine(grinderPen, 0, (float)(B + L - N), wheelCentreX, wheelCentreY)
        }
Exemple #4
0
        private void computeGrinder()
        {
            double prevOffset = 0;
            CompGeometry cg = new CompGeometry();

            for (double alpha = Constants.R90; alpha >= 0; alpha -= Change.toRadians(STEPSIZE) )
            {
                Polar offset = new Polar(cg.compGrinderOffset(alpha) - Data.dBaseRadius - Data.dWheelDiameter/2, alpha);

                if (prevOffset != 0 && Math.Abs((offset.r - prevOffset)) > 0.001)
                {
                    double x = Change.toDegrees(alpha);
                }
                prevOffset = offset.r;

                pGrinder.Add(offset);
                double lift = offset.r;
                pLift.Add(new Polar(lift, alpha));
                if (lift > maxGrind.r) { maxGrind = new Polar(lift, alpha); }
                if (lift < minGrind.r) { minGrind = new Polar(lift, alpha); }
            }
        }
Exemple #5
0
        public override Boolean isValid()
        {
            saveData();

            lblError.Text = "";
            String err = "";

            Data.sName = txtName.Text;
            Data.sDescription = txtDescription.Text;
            Data.sUnits = radioUnits.SelectedValue;

            if (!Data.setBaseRadiusIfDouble(txtBaseRadius.Text))
            {
                err += "Base radius must be a number.<br />";
            }

            if (!Data.setLiftIfDouble(txtValveLift.Text))
            {
                err += "Lobe lift must be a number.<br />";
            }

            if (!Data.setFlankRadiusIfDouble(txtFlankRadius.Text))
            {
                err += "Flank radius must be a number.<br />";
            }

            if (!Data.setActionIfDouble(txtAction.Text))
            {
                err += "Action angle must be a number.<br />";
            }
            else
            {
                if (Data.dAction <= 10 || Data.dAction >= 180)
                {
                    err += "Duration angle must be between 10 and 180.<br />";
                }
                else
                {
                    Data.dAction = Change.toRadians(Data.dAction);
                }
            }

            if (!Data.setRpmIfInteger(txtRpm.Text))
            {
                err += "RPM must be a number.<br />";

            }
            else
            {
                if (Data.iRpm < 0 || Data.iRpm >= 50000)
                {
                    err += "RPM must be 0 - 50,000.<br />";
                }
            }

            if (!Data.setDecimalsIfInteger(txtDecimals.Text))
            {
                err += "Decimals must be a number." + Environment.NewLine;
            }
            else
            {
                if (Data.iDecimals < 0 || Data.iDecimals >= 8)
                {
                    err += "Decimals must be 0 - 8.<br />";
                }
            }

            if (err.Equals(""))
            {
                if ((Data.dBaseRadius + Data.dLift) > 1000)
                {
                    err += "Cam height greater than 1,000 Cannot be calculated by GCam.<br />";
                }
            }

            try
            {
                CompGeometry cg = new CompGeometry();
            }
            catch (Exception e)
            {
                err += e.Message + "<br />";
            }

            if (!err.Equals(""))
            {
                Data.setOutstandingError(Constants.GEOMETRY, true);
                lblError.Text = err;
                lblErrHead.Visible = true;
                return false;
            }

            lblErrHead.Visible = false;
            Data.setOutstandingError(Constants.GEOMETRY, false);
            return true;
        }
Exemple #6
0
        private void setup(bool zoomed)
        {
            CompGeometry cg = new CompGeometry();
            F = Data.dFlankRadius;                // flank radius
            B = Data.dBaseRadius;                 // base radius
            L = Data.dLift;						  // lift
            N = Data.dNoseRadius;				  // nose radius

            if (zoomed)
            {
                unitsPerInch = 72;
                diagramSize = 10f * unitsPerInch;
                image = new Bitmap(962, 962);
            }
            else
            {
                unitsPerInch = 72;
                diagramSize = 4f * unitsPerInch;
                //image = new Bitmap(480, 480);
                image = new Bitmap(385, 385);
            }

            // Compute diagram height
            float camHeight = (float)(2 * (B + L));
            float camRoundedHeight = NextHigher.get(camHeight * 1.1);
            float scale = diagramSize / camRoundedHeight;

            gridSize = diagramSize / 10 / scale;

            // OriginX/Y is centre of base circle
            float originX = gridSize * 5;
            // Number grid squares to accomodate base radius
            float baseSquares = (float)(Math.Ceiling(B / gridSize));
            float originY = gridSize * 5;			// (float)((10 - baseSquares) * gridSize);

            Graphics graphics = Graphics.FromImage(image);
            graphics.PageUnit = GraphicsUnit.Point;

            g = new GGraphics(graphics, scale, originX, originY);
        }