Diagonal line?

Hi, I want to do a simple calculation for crossing 2 lines together but cannot get it after tried the program below.
The program below cannot cross the center of the horizontal line, I don't know what's the mistake, can anyone help? Thanks...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
static int w=250, h=150;
int x=w/4, y=h/2,a=w/4,b=h/4;
int i,j;
.
.
.
.
.

for (i = 0; i<(w/2); i++) {
SetPixel(hdc, x, y, RGB(255, 255, 0));
//y = h/2;
x = x+1;

}

for(i=0; i<(w/2); i++){
SetPixel(hdc, a, b, RGB(255, 0, 0));
a = a + 1;
b= b + 1;
for(j=0; j<1; j++){
SetPixel(hdc, a, b, RGB(255, 0, 0));
a = a + 1;
b= b + 1;
}
}
Last edited on
What kind of result do you expect to get? crossing 2 lines in mathematics requires just solving a simple first order linear algebraic equation... why don't you do that?
Hi, I need to fill in the pixel by pixel, that's why I need to do that...Or maybe I misunderstood? Pls correct me since I'm new in this Win32 Programming...TQ...
I'm sorry, but I feel I'm forced to ask the question again. What kind of result do you expect to get? I mean are you plotting 2 perpendicular lines? how do you define the slope and the intersection of these line on the coordinate system of the widget you're plotting on? please explain everything you want to do from the beginning to the end, briefly.
Hi, this is what I want to get actually...

http://img195.imageshack.us/img195/9265/020412.png

I want to get this(Top image) as the red line cross the yellow line at the center of yellow line but then I get the one below it (red line not crossing yellow line at the center)...

Details:

int x=w/4, y=h/2,a=w/4,b=h/4;
This is the initial pixel of red line and yellow line

The 1st for loop is to draw the yellow line (Horizontal)

the 2nd and 3rd for loop is to draw the red line

Can I know the reason that I can't get the 1st image? Thanks...

Topic archived. No new replies allowed.