gradient function

Hello, Im trying to do some very basic algebra in c++, im not using any maths libraries. I have my midpoint calculator working ok but when trying to calculate the rise and run of 2 points on a grid Im getting wrong results especially where answers are negitive. Im not looking for code im just needing some advice on how I go about it in programming.

This is not homework it's just me fiddling about.
What coordinate system are you working in?
two dimension cartesian coordinate plane.


go back to the mathematical definitions:

given p1 = (x1,y1), p2 = (x2,y2),
rise( p1, p2 ) = y2 - y1
run( p1, p2 ) = x2 - x1
Topic archived. No new replies allowed.