LandR
Graduate Poster
- Joined
- Sep 20, 2009
- Messages
- 1,280
Hi,
I have a bit of a maths problem. I am drawing some triangles to screen with my program but my program draws to a paintbox (.net).
The left most coordinate of the paintbox is 0, the rightmost is 500. It's 500 pixels wide by 500 pixels high.
On this box I have drawn axis and a grid labelled from -1000 > 0 > 1000 for both X and Y axis.
The coordinates of the any vertex on the triangles range from (-1000,-1000) to (1000,1000).
I obviously can't draw them straight to the screen with these coordinates but my maths is so rusty. How can I transform the triangles co-ordinates so that:
-1000 = 0;
0 = 250
1000 = 500
??
I can write code to transform the coordinates I'm just not sure how I should go about it.
The initial problem was to find out of 1000 triangles how many contained the origin with their area. This I solved, it was simple enough. I decided though I would learn some graphics programming and allow you to draw the triangles to screen along with showing the calculations.
Sorry for being thick and Thank You if you help!
I have a bit of a maths problem. I am drawing some triangles to screen with my program but my program draws to a paintbox (.net).
The left most coordinate of the paintbox is 0, the rightmost is 500. It's 500 pixels wide by 500 pixels high.
On this box I have drawn axis and a grid labelled from -1000 > 0 > 1000 for both X and Y axis.
The coordinates of the any vertex on the triangles range from (-1000,-1000) to (1000,1000).
I obviously can't draw them straight to the screen with these coordinates but my maths is so rusty. How can I transform the triangles co-ordinates so that:
-1000 = 0;
0 = 250
1000 = 500
??
I can write code to transform the coordinates I'm just not sure how I should go about it.
The initial problem was to find out of 1000 triangles how many contained the origin with their area. This I solved, it was simple enough. I decided though I would learn some graphics programming and allow you to draw the triangles to screen along with showing the calculations.
Sorry for being thick and Thank You if you help!