Exemplo n.º 1
0
        public void Draw()
        {
            GL.PushMatrix();

            GL.Translate(0, 0, -0.1);
            Vector3 p = device.GetPosition();

            CoolDrawing.DrawCircle(12.5f, new OpenTK.Vector2(p.X * 1000, p.Y * 1000), Color.DarkGreen);

            for (int i = 0; i < commands.Count(); i++)
            {
                if (commands[i] is MoveTool)
                {
                    MoveTool m             = commands[i] as MoveTool;
                    Vector3  finalPosition = m.FinalPosition();
                    CoolDrawing.DrawCircle(5.0f, new Vector2(finalPosition.X * 1000, finalPosition.Y * 1000), Color.Blue);
                }
            }

            for (int i = 0; i < previousPoints.Count(); i++)
            {
                double age = DateTime.Now.Subtract(previousPoints[i].createTime).TotalMilliseconds;
                if (age > 5000)
                {
                    previousPoints.RemoveAt(i);
                    i--;
                }
                else
                {
                    int alpha = (int)(255 - 255 * age / 5000.0f);
                    CoolDrawing.DrawCircle(5.0f, new Vector2(previousPoints[i].location.X * 1000, previousPoints[i].location.Y * 1000), Color.FromArgb(alpha, Color.DarkGreen));
                }
            }

            float w = 0;

            // Assume full bit penetrates at 20 mills depth
            if (p.Z < 0)
            {
                w = -p.Z / .020f * 12.5f;
                if (w > 12.5f)
                {
                    w = 12.5f;
                }
                CoolDrawing.DrawFilledCircle(w, new OpenTK.Vector2(p.X * 1000, p.Y * 1000), Color.FromArgb(100, Color.OrangeRed));
                if (p.Z < -.020)
                {
                    float t = (p.Z + .020f) / .040f * 12.5f;
                    CoolDrawing.DrawFilledCircle(t, new OpenTK.Vector2(p.X * 1000, p.Y * 1000), Color.FromArgb(100, Color.DarkRed));
                }
            }
            else
            {
                w = p.Z / move_height * 12.5f;
                CoolDrawing.DrawFilledCircle(w, new OpenTK.Vector2(p.X * 1000, p.Y * 1000), Color.FromArgb(100, Color.LightGreen));
            }

            GL.PopMatrix();
        }
Exemplo n.º 2
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.º 3
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.º 4
0
        public virtual void Draw()
        {
            if (is_display_list_good)
            {
                GL.CallList(displayList);
            }
            else
            {
                if (displayList < 0)
                {
                    displayList = GL.GenLists(1);
                }

                GL.NewList(displayList, ListMode.CompileAndExecute);
                List <CoolDrawing.Line> lines = new List <CoolDrawing.Line>();
                if (Points.Count >= 2)
                {
                    for (int i = 0; i < (Points.Count - 1); i++)
                    {
                        lines.Add(new CoolDrawing.Line(new Vector2(Points[i].X, Points[i].Y), new Vector2(Points[i + 1].X, Points[i + 1].Y)));
                    }
                    CoolDrawing.DrawDepthLine(width, lines.ToArray(), this.Depth);
                }
                for (int i = 0; i < Points.Count; i++)
                {
                    Vector2 p = Points[i];


                    if (closestIsPoint && (i == closestPoint) && isMouseLDown)
                    {
                        CoolDrawing.DrawFilledCircle(width / 2, new Vector2(p.X, p.Y), Color.FromArgb(100, Color.Purple));
                    }
                    else
                    {
                        //CoolDrawing.DrawFilledCircle(width / 2, new Vector2(p.X, p.Y), Color.White);
                    }
                    CoolDrawing.DrawCircle(width / 2, new Vector2(p.X, p.Y), Color.Black);
                }
                GL.EndList();
                is_display_list_good = true;
            }
        }
Exemplo n.º 5
0
        public void Draw()
        {
            float contact_circumference = circular_pitch * teeth;

            double contact_radius = contact_circumference / (Math.PI * 2);
            double base_radius    = contact_radius * Cosd(pressure_angle);

            double outer_radius = contact_radius + addendum;
            double inner_radius = contact_radius - dedendum;

            CoolDrawing.DrawCircle((float)base_radius, Center, Color.Black);
            CoolDrawing.DrawCircle((float)contact_radius, Center, Color.Orange);
            CoolDrawing.DrawCircle((float)outer_radius, Center, Color.DarkBlue);
            CoolDrawing.DrawCircle((float)inner_radius, Center, Color.DarkBlue);

            double theta_to_contact_radius = Degrees(Sind(pressure_angle) / Cosd(pressure_angle));

            List <Rout> Routs = new List <Rout>();

            float a_radians = (float)(Math.PI * (0 - (theta_to_contact_radius - pressure_angle)) / 180.0f);

            // Draw an involute curve off the surface of the gear
            GL.Begin(BeginMode.LineStrip);
            GL.Color3(Color.Black);

            // Create routs to match the drawn line
            Rout rt = new Rout();

            rt.Width = this.width;

            // Line from inner radius to start of base circle
            double sin_theta = (float)Math.Sin(a_radians);
            double cos_theta = (float)Math.Cos(a_radians);

            if (inner_radius < base_radius)
            {
                double x = inner_radius * cos_theta + this.X;
                double y = inner_radius * sin_theta + this.Y;
                GL.Vertex2(x, y);
                x = base_radius * cos_theta + this.X;
                y = base_radius * sin_theta + this.Y;
                GL.Vertex2(x, y);
            }

            // Degrees to rotate while drawing involute curve from base_radius to outer_radius
            float distance = (float)Degrees(Math.Sqrt(outer_radius * outer_radius - base_radius * base_radius) / base_radius);

            // Draw an involute line from base_radius to outer_radius
            for (double theta = 0; theta <= (distance + .0001); theta += (distance / 20.0f))
            {
                Vector2 point = ComputeInvolutePoint(theta, Degrees(a_radians), base_radius, 0);
                GL.Vertex2(point + Center);
            }
            GL.End();

            //outerRout.Draw();
            foreach (Rout a in this.GetRouts())
            {
                a.Draw();
            }
        }