Exemplo n.º 1
0
        public override void Draw()
        {
            for (int i = 0; i < (Points.Count - 1); i++)
            {
                Color c = Color.OrangeRed;
                CoolDrawing.DrawLine(width, new Vector2(Points[i].X, Points[i].Y), new Vector2(Points[i + 1].X, Points[i + 1].Y), c);
                CoolDrawing.DrawFilledCircle(width / 2, new Vector2(Points[i].X, Points[i].Y), c);
            }

            CoolDrawing.DrawFilledCircle(width / 2, center, Color.LightGreen);
            CoolDrawing.DrawCircle(width / 2, center, Color.Black);
        }
Exemplo n.º 2
0
        public void Draw()
        {
            double pitch       = 80;
            double tooth_width = 45; // outside tooth width (part that fits into the pulley)
            double c           = this.teeth * pitch;

            double r = (c / (2 * Math.PI));

            for (int i = 0; i < this.teeth; i++)
            {
                double theta_total = ((double)1 / (double)this.teeth) * 2.0 * Math.PI;
                double theta_b     = (tooth_width / pitch) * theta_total;
                double theta_a     = (theta_total - theta_b) / 2.0;

                double theta_start = (double)i * theta_total;

                Vector2 a1 = new Vector2((float)(Math.Cos(theta_start) * r), (float)(Math.Sin(theta_start) * r));
                Vector2 a2 = new Vector2((float)(Math.Cos(theta_start + theta_a) * r), (float)(Math.Sin(theta_start + theta_a) * r));
                Vector2 a3 = new Vector2((float)(Math.Cos(theta_start + theta_a + theta_b) * r), (float)(Math.Sin(theta_start + theta_a + theta_b) * r));
                Vector2 a4 = new Vector2((float)(Math.Cos(theta_start + theta_a + theta_b + theta_a) * r), (float)(Math.Sin(theta_start + theta_a + theta_b + theta_a) * r));

                double  w  = (Math.Tan(tooth_taper_angle) * tooth_depth) / pitch * theta_total;
                Vector2 b1 = new Vector2((float)(Math.Cos(theta_start + theta_a + w) * (r - tooth_depth)), (float)(Math.Sin(theta_start + theta_a + w) * (r - tooth_depth)));
                Vector2 b2 = new Vector2((float)(Math.Cos(theta_start + theta_a + theta_b - w) * (r - tooth_depth)), (float)(Math.Sin(theta_start + theta_a + theta_b - w) * (r - tooth_depth)));

                CoolDrawing.DrawLine(1, a2 + this.Center, b1 + this.Center, Color.DarkBlue);
                CoolDrawing.DrawLine(1, b1 + this.Center, b2 + this.Center, Color.Red);
                CoolDrawing.DrawLine(1, b2 + this.Center, a3 + this.Center, Color.DarkBlue);

                CoolDrawing.DrawLine(1, a1 + this.Center, a2 + this.Center, Color.Red);
                CoolDrawing.DrawLine(1, a3 + this.Center, a4 + this.Center, Color.DarkGreen);



                Vector2 p1 = new Vector2((float)(Math.Cos(theta_start) * radius), (float)(Math.Sin(theta_start) * radius));
                Vector2 p2 = new Vector2((float)(Math.Cos(theta_start) * r), (float)(Math.Sin(theta_start) * r));
                CoolDrawing.DrawLine(1, this.Center + p1, p2 + this.Center, Color.Black);
            }
            CoolDrawing.DrawCircle(radius, Center, Color.Black);

            foreach (Rout rout in this.GetRouts())
            {
                rout.Draw();
            }

            CoolDrawing.DrawFilledCircle(width / 2, Center, Color.LightGreen);
            CoolDrawing.DrawCircle(width / 2, Center, Color.Black);
        }
Exemplo n.º 3
0
        private void ComputePoints()
        {
            outerRout       = new Rout();
            outerRout.Width = width;
            outerRout.Depth = depth;

            double pitch       = 80;
            double tooth_width = 45; // outside tooth width (part that fits into the pulley)

            double c = this.teeth * pitch;

            double r  = (c / (2 * Math.PI));
            double tr = this.width / 2; // tool radius

            for (int i = 0; i < this.teeth; i++)
            {
                //double pulley_tooth_center = (double)i;
                double theta_total = ((double)1 / (double)this.teeth) * 2.0 * Math.PI;
                double theta_b     = (tooth_width / pitch) * theta_total;
                double theta_a     = (theta_total - theta_b) / 2.0;

                double theta_start = (double)i * theta_total;

                Vector2 a1 = new Vector2((float)(Math.Cos(theta_start) * r), (float)(Math.Sin(theta_start) * r));
                Vector2 a2 = new Vector2((float)(Math.Cos(theta_start + theta_a) * r), (float)(Math.Sin(theta_start + theta_a) * r));
                Vector2 a3 = new Vector2((float)(Math.Cos(theta_start + theta_a + theta_b) * r), (float)(Math.Sin(theta_start + theta_a + theta_b) * r));
                Vector2 a4 = new Vector2((float)(Math.Cos(theta_start + theta_a + theta_b + theta_a) * r), (float)(Math.Sin(theta_start + theta_a + theta_b + theta_a) * r));

                double  w  = (Math.Tan(tooth_taper_angle) * tooth_depth) / pitch * theta_total;
                Vector2 b1 = new Vector2((float)(Math.Cos(theta_start + theta_a + w) * (r - tooth_depth)), (float)(Math.Sin(theta_start + theta_a + w) * (r - tooth_depth)));
                Vector2 b2 = new Vector2((float)(Math.Cos(theta_start + theta_a + theta_b - w) * (r - tooth_depth)), (float)(Math.Sin(theta_start + theta_a + theta_b - w) * (r - tooth_depth)));

                CoolDrawing.DrawLine(1, a2 + this.Center, b1 + this.Center, Color.DarkBlue);
                CoolDrawing.DrawLine(1, b1 + this.Center, b2 + this.Center, Color.Red);
                CoolDrawing.DrawLine(1, b2 + this.Center, a3 + this.Center, Color.DarkBlue);

                CoolDrawing.DrawLine(1, a1 + this.Center, a2 + this.Center, Color.Red);
                CoolDrawing.DrawLine(1, a3 + this.Center, a4 + this.Center, Color.DarkGreen);

                Vector2 p = new Vector2((float)(Math.Cos(theta_start) * r), (float)(Math.Sin(theta_start) * r));
                CoolDrawing.DrawLine(1, this.Center, p + this.Center, Color.Black);

                // Tool Path

                double tw = tr * Math.Tan(0.25 * Math.PI - tooth_taper_angle / 2) / pitch * theta_total;

                Vector2 t1 = this.Center + new Vector2((float)(Math.Cos(theta_start) * (r + tr)), (float)(Math.Sin(theta_start) * (r + tr)));
                Vector2 t2 = this.Center + new Vector2((float)(Math.Cos(theta_start + theta_a + tw) * (r + tr)), (float)(Math.Sin(theta_start + theta_a + tw) * (r + tr)));
                Vector2 t3 = this.Center + new Vector2((float)(Math.Cos(theta_start + theta_a + theta_b - tw) * (r + tr)), (float)(Math.Sin(theta_start + theta_a + theta_b - tw) * (r + tr)));
                Vector2 t4 = this.Center + new Vector2((float)(Math.Cos(theta_start + theta_a + theta_b + theta_a) * (r + tr)), (float)(Math.Sin(theta_start + theta_a + theta_b + theta_a) * (r + tr)));

                Vector2 tb1 = this.Center + new Vector2((float)(Math.Cos(theta_start + theta_a + w + tw) * (r - tooth_depth + tr)), (float)(Math.Sin(theta_start + theta_a + w + tw) * (r - tooth_depth + tr)));
                Vector2 tb2 = this.Center + new Vector2((float)(Math.Cos(theta_start + theta_a + theta_b - w - tw) * (r - tooth_depth + tr)), (float)(Math.Sin(theta_start + theta_a + theta_b - w - tw) * (r - tooth_depth + tr)));

                //CoolDrawing.DrawLine((float)tr * 2, t1 + this.center, t2 + this.center, toolColor);
                //CoolDrawing.DrawLine((float)tr * 2, t2 + this.center, tb1 + this.center, toolColor);
                //CoolDrawing.DrawLine((float)tr * 2, tb1 + this.center, tb2 + this.center, toolColor);
                //CoolDrawing.DrawLine((float)tr * 2, tb2 + this.center, t3 + this.center, toolColor);
                //CoolDrawing.DrawLine((float)tr * 2, t3 + this.center, t4 + this.center, toolColor);

                outerRout.Points.Add(new Vector2(t1.X, t1.Y));
                outerRout.Points.Add(new Vector2(t2.X, t2.Y));
                outerRout.Points.Add(new Vector2(tb1.X, tb1.Y));
                outerRout.Points.Add(new Vector2(tb2.X, tb2.Y));
                outerRout.Points.Add(new Vector2(t3.X, t3.Y));
                outerRout.Points.Add(new Vector2(t4.X, t4.Y));
            }

            innerRout       = new Rout();
            innerRout.Width = width;
            innerRout.Depth = center_hole_depth;

            float circumference = (float)Math.PI * 2 * radius;

            //int _pointCount = pointCount;
            //if (_pointCount <= 1)
            //{
            int _pointCount = (int)(0.5f * circumference / width);

            if (_pointCount <= 12)
            {
                _pointCount = 12;
            }

            for (int i = 0; i <= _pointCount; i++)
            {
                Vector2 p = new Vector2((float)(Math.Cos(Math.PI * 2 * i / _pointCount) * (radius - tr)), (float)(Math.Sin(Math.PI * 2 * i / _pointCount) * (radius - tr)));
                p += Center;
                innerRout.Points.Add(new Vector2(p.X, p.Y));
            }

            //base.HasChanged = true;
        }