gradient function

May 6, 2011 at 9:16am
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.
May 6, 2011 at 10:10am
What coordinate system are you working in?
May 6, 2011 at 10:38am
two dimension cartesian coordinate plane.


May 6, 2011 at 12:35pm
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.