Page 1 of 1

noobie c++ help please

Posted: Wed Mar 05, 2008 9:29 pm
by losCHUNK
is this the correct way to calculate a gradient between points ?

double aaa=0.00, bbb=0.00;
aaa= y2-y1;
bbb= x2-x1;

gradient = aaa/bbb;

?

ty :)

Re: noobie c++ help please

Posted: Wed Mar 05, 2008 9:54 pm
by menkent
the math is correct for the slope between (x1,y1) and (x2,y2) if that's what you're asking.

Re: noobie c++ help please

Posted: Wed Mar 05, 2008 9:59 pm
by losCHUNK
thats it thanks mate

cheers :)

Re: noobie c++ help please

Posted: Wed Mar 05, 2008 10:07 pm
by PhoeniX
Or you could save some lines and just do;
gradient = y2-y1/x2-x1;

Re: noobie c++ help please

Posted: Wed Mar 05, 2008 10:11 pm
by MKJ
he might need the aaa and bbb later.

Re: noobie c++ help please

Posted: Wed Mar 05, 2008 11:01 pm
by r3t
what has this to do with c++?

Re: noobie c++ help please

Posted: Thu Mar 06, 2008 8:42 am
by ^misantropia^
menkent wrote:the math is correct for the slope between (x1,y1) and (x2,y2) if that's what you're asking.
Save that he doesn't check for division by zero.

Re: noobie c++ help please

Posted: Thu Mar 06, 2008 12:33 pm
by hax103
PhoeniX wrote:Or you could save some lines and just do;
gradient = y2-y1/x2-x1;
well, since one might just "copy" the above, i think the above is not correct.

to be specific, it would equal to

gradient = y2 - (y1/x2) - x1 when he really wants

gradient = (y2-y1) / (x2-x1);

Re: noobie c++ help please

Posted: Thu Mar 06, 2008 7:12 pm
by Cory
Hey guys can you help me with an ASP.NET problem?

What is the formula to find the midpoint of a line?

Re: noobie c++ help please

Posted: Thu Mar 06, 2008 7:23 pm
by Don Carlos
line divided by two

Re: noobie c++ help please

Posted: Wed Mar 12, 2008 1:17 am
by losCHUNK
new question :D

how would i calculate the intercept of Y ?