|
-
Apr 1st, 2008, 04:40 PM
#1
Thread Starter
Hyperactive Member
VS2005 C# a line from the center of a circle to a random point on the diameter of t
How to draw a line from the center of a circle to a random point on the diameter of that circle.
I am hoping to make a lil' proggy that will help improve my ability to read dials at work. I removed the dial numbers and just want to be able to read them by position. So far I have the five circles drawing up right where I want them on the form. I can draw a line, but I can't figure out how to have the line go to random points on the diameter. I imagine that what I'll need it to do is draw itself from a center location to the diameter's edge. A random numbered degree 1-360 I am guessing. Then once that's working take a number of the degrees and assign them to a number of the dial. So a range of 1-10' might be the numeral one on the dial.
Well, I can only hope that this could work out something like that.
Anyways here's what I have so far. I really don't know what I am doing, but I would really appreciate some assistance in having such a handy app to study from. I can print out a hundred sheets and just right on them, but this iiiiis 2008 so maybe some software would be ideal; SAVE THE TREES? hehe
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MeterDials
{
public partial class DialsForm : Form
{
public DialsForm()
{
InitializeComponent();
}
private void DialsForm_Load(object sender, EventArgs e)
{
}
private void Bttn_Reset_Click(object sender, EventArgs e)
{
System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.DrawLine(myPen, 0, 0, 200, 200);
myPen.Dispose();
formGraphics.Dispose();
}
private void DialsForm_Paint_1(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen mypen = new Pen(Color.Black, 2);
SolidBrush mybrush = new SolidBrush(Color.Blue);
//g.FillEllipse(mybrush, 10, 50, 150, 150);
g.DrawEllipse(mypen, 20, 20, 100, 100);
g.DrawEllipse(mypen, 140, 20, 100, 100);
g.DrawEllipse(mypen, 260, 20, 100, 100);
g.DrawEllipse(mypen, 380, 20, 100, 100);
g.DrawEllipse(mypen, 500, 20, 100, 100);
}
}
}
A sample I found that may help figure something out:
Edge coordinates:
x_edge coordinate = x_center + Math.Cos(u) * radius
y_edge coordinate = y_center - Math.Sin(u) * radius
where u is the angle measured in radians. To convert from degrees to radians, use: degrees * Math.PI / 180.
Where I have no idea where to begin with this.
Thank you so much for your time in reviewing this.
Thanks in advance for any assistance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|