noobie c++ help please

Open discussion about any topic, as long as you abide by the rules of course!
Post Reply
losCHUNK
Posts: 16019
Joined: Thu May 09, 2002 7:00 am

noobie c++ help please

Post 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 :)
[color=red] . : [/color][size=85] You knows you knows [/size]
menkent
Posts: 2629
Joined: Sun Jul 23, 2000 7:00 am

Re: noobie c++ help please

Post by menkent »

the math is correct for the slope between (x1,y1) and (x2,y2) if that's what you're asking.
losCHUNK
Posts: 16019
Joined: Thu May 09, 2002 7:00 am

Re: noobie c++ help please

Post by losCHUNK »

thats it thanks mate

cheers :)
[color=red] . : [/color][size=85] You knows you knows [/size]
User avatar
PhoeniX
Posts: 4067
Joined: Fri Aug 04, 2000 7:00 am

Re: noobie c++ help please

Post by PhoeniX »

Or you could save some lines and just do;
gradient = y2-y1/x2-x1;
User avatar
MKJ
Posts: 32582
Joined: Fri Nov 24, 2000 8:00 am

Re: noobie c++ help please

Post by MKJ »

he might need the aaa and bbb later.
r3t
Posts: 701
Joined: Tue Feb 08, 2005 9:58 am

Re: noobie c++ help please

Post by r3t »

what has this to do with c++?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: noobie c++ help please

Post 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.
hax103
Posts: 232
Joined: Fri Aug 05, 2005 2:04 pm

Re: noobie c++ help please

Post 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);
-
old nik (q3w): hack103
Cory
Posts: 185
Joined: Thu Mar 31, 2005 4:17 pm

Re: noobie c++ help please

Post by Cory »

Hey guys can you help me with an ASP.NET problem?

What is the formula to find the midpoint of a line?
Don Carlos
Posts: 17509
Joined: Thu Jan 01, 1970 12:00 am

Re: noobie c++ help please

Post by Don Carlos »

line divided by two
losCHUNK
Posts: 16019
Joined: Thu May 09, 2002 7:00 am

Re: noobie c++ help please

Post by losCHUNK »

new question :D

how would i calculate the intercept of Y ?
[color=red] . : [/color][size=85] You knows you knows [/size]
Post Reply