%mathpiper,def="Slope"

10 # Slope(PointA_IsPoint,PointB_IsPoint) <--
[
    Local(x1,x2,y1,y2,slope);

    x1 := PointA[1];
    x2 := PointB[1];
    y1 := PointA[2];
    y2 := PointB[2];
    
    slope := (y2 - y1)/(x2 - x1);
];



10 # Slope(segment_IsList)_(Length(segment) = 2 And Length(segment[1]) = 2 And Length(segment[2]) = 2) <--
[
    Local(x1,x2,y1,y2,slope);
    
    x1 := segment[1][1]; //PointA[1];
    x2 := segment[2][1]; //PointB[1];
    
    
    y1 := segment[1][2]; //PointA[2];
    y2 := segment[2][2]; //PointB[2];

    slope := (y2 - y1)/(x2 - x1);
];

%/mathpiper



%mathpiper_docs,name="Slope",categories="User Functions;Analytic Geometry",access="experimental",access="experimental"
*CMD Slope --- returns the slope of a line which is represented by two points
*STD
*CALL
	Slope(p1, p2)
	Slope(Segment(p1, p2))
*PARMS

{p1} -- the first point

{p2} -- the second point

*DESC

This function calculates the slope between two points or of a 
segment using the slope formula.

*E.G.

In> PointA := Point(2,3)
Result: {2,3}
	
In> PointB := Point(6,8)
Result: {6,8}
	
In> Slope(PointA,PointB)
Result: 5/4

In> s := Segment(PointA,PointB)
Result: {{2,3},{6,8}}
	
In> Slope(s)
Result: 5/4

*SEE IsPoint, Point, Distance, Midpoint, Segment
%/mathpiper_docs
