Using double with Graphics.DrawLine

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys

I was playing around last nite (as u do, hot coffee in hand) with a simple cube drawing based on an array made up of x,y coords (I know I can use Point but I haven't got that far yet).

Basically, I got the cube to draw onscreen, but now I want 2 buttons to make the cube rotate left and right. I've added the buttons, and the following code...

dansBox[0,0] = dansBox[0,0] * Math.Cos(angle) - dansBox[0,1] * Math.Sin(angle);
dansBox[0,1] = dansBox[0,1] * Math.Cos(angle) + dansBox[0,0] * Math.Sin(angle);

...but I'm having a problem.

Having converted the object and related variables to "double", I'm now getting errors that DrawLine will not accept a double as a parameter. How can I solve this to see how my maths is? (bad probably!)

Any help appreciated.

Cheers


Dan
 
Hi Dan,

You cast the double to float.

DrawLine(MyPen, (float)mydoublevalue, (float)myotherdoublevalue ...
 
Cool!

Thanks Morten - worked great. In fact with a bit more coding the whole project works now (well almost).

Basically I'm drawing a box on the screen, and using 2 buttons to rotate it. This is now working. However, it appears to be rotating on the first point of the cube (top left of the cube as we look at it) rather than rotating around it's own center.

Any ideas on how to fix this? I know this is a Math thing rather than specific code, so forgive me if I should post somewhere else......

Cheers


Dan
 
Back
Top