Unable to do the maths behind problem 10

Back to Problem Solutions forum

ugsdhfjbnsja     2015-06-27 17:09:02

I am fine at programming (I think), but I am really stuglling with the maths behind problem 10. As far as I can see, the problem is just a variation of finding m and c from the straight line graph equation y=mx+c. Therefore I am trying to calculate m as "change in x / change in y", however, my answers are not coming out at all like the solutions.

    changeInX = point2x-point1x;
    changeInY = point2y-point1y;

    gradient = changeInX/changeInY;                         // m
    offset = point1y-(gradient*(point1x));                  // c

I thought this was right, but I get 0 (I haven't bothered with rounding yet) for all the m values.

ugsdhfjbnsja     2015-06-27 19:01:43

UPDATE:

I'm a moron. I got the X and Y positions in the division the wrong way around. This took me longer than I would care to admit to fix.

Please login and solve 5 problems to be able to post at forum