473,466 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using double with Graphics.DrawLine

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
Nov 16 '05 #1
3 4086
Hi Dan,

You cast the double to float.

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

--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
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

"Morten Wennevik" wrote:
Hi Dan,

You cast the double to float.

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

--
Happy coding!
Morten Wennevik [C# MVP]

Nov 16 '05 #3
Sorry, can't help you there.

--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Vin | last post by:
Hi, I am using the following code to draw whatever the user draws using x,y. // draws lines directly on a winform. CreateGraphics().DrawLine(APen, x, y, OldX, OldY); Now how do I save the...
2
by: Coralin Feierbach | last post by:
I created a Windows Form Project using VS.net. I'm trying to draw a line between two points. (Plotting a graph, dynamically) This is the code I have so far: What do I have to do to actually see...
3
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
0
by: Carl Gilbert | last post by:
Hi I am trying to draw a pie like shape on a form in the paint event. I am then trying to draw a line running down the center of the pie. The code I have attached at the bottom of this post...
0
by: matko | last post by:
When I call the following function, the rectangle will overlap the graphics that is drawn _afterwards_. Why is that? How can I make sure my graphics is drawn in correct order? (Note: If I...
17
by: Galen Somerville | last post by:
The following code just shows a small portion of the overall Graphics on my Sweep form. I set the Panel to a medium Grey color so it stands out on a Windows Grey screen. The first thing that...
2
by: rushikesh.joshi | last post by:
Hi All, I want to create a webcontrol which will generate a bar (bar chart). I have done some graphics code in my ASPX page and it's working fine, but how do i create a Custom Control or User...
2
by: Overseer | last post by:
What is the best way to draw graphics like Task Manager's Performance Graphic??
1
by: Ringo | last post by:
I need some help. I have an app that talks to a sonar board via the serial port. In my sp_DataReceived I gather all the data and put it into arrays. Then I want to draw the data in a pictureBox. I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.