The online racing simulator
Graphics in C#
(4 posts, started )
Graphics in C#
Hi there. I'm trying to make a speedo/RPM counter, and I'm planning to do it by drawing a line (needle) onto a form, with a dial set as the background. The problem I've come up against however, is trying to draw the line properly.

I have the angle that the line needs to be drawn at, and I have the distance I want it drawn from the centre point. But I can't seem to find any piece of trigonometry that will tell me the points that I will end up drawing to, or even better, something in C# that will be able to draw using an angle, a starting point, and the distance.

I've spent a good bit of time trying to work around it, but any other way ended up being completely inaccurate and/or just didn't do it at all...

EDIT: Solved...

x_edge coordinate = x_center + Math.Cos(u) * radius
y_edge coordinate = y_center - Math.Sin(u) * radius
a quick google search would have found you a "wheel". don't reinvent it.

http://www.codeproject.com/KB/miscctrl/A_Gauge.aspx

i was gonna use this for an idea i had for outgauge, but never got around to it.

PS. yeah, i see your edit, but others may find some use for the code too
Quote from burnsy1882 :a quick google search would have found you a "wheel". don't reinvent it.

http://www.codeproject.com/KB/miscctrl/A_Gauge.aspx

i was gonna use this for an idea i had for outgauge, but never got around to it.

PS. yeah, i see your edit, but others may find some use for the code too

Just took a look at that, don't know how I didn't see it Really useful, I'm probably going to just use that altogether...Thanks
The maths you are looking for are linear algebra, not trigonometry (well, trig is used to compose the rotation matrices, but you won't have to deal with that directly). Just make a single fixed quad (two polygon square) of unit size, and then scale, translate and rotate it into place using matrices each frame. Both directx and opengl provide hardware accelerated vertex transformation for you, and will give you more versatility than the GDI based approach above, if you are willing to learn.

Graphics in C#
(4 posts, started )
FGED GREDG RDFGDR GSFDG