MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Slope

Function Slope

math/geometry/straightlines.go:32–34  ·  view source on GitHub ↗

Slope calculates the slope (gradient) of a line.

(l *Line)

Source from the content-addressed store, hash-verified

30
31// Slope calculates the slope (gradient) of a line.
32func Slope(l *Line) float64 {
33 return (l.P2.Y - l.P1.Y) / (l.P2.X - l.P1.X)
34}
35
36// YIntercept calculates the Y-Intercept of a line from a specific Point.
37func YIntercept(p *Point, slope float64) float64 {

Callers 3

TestSlopeFunction · 0.85
IsParallelFunction · 0.85
IsPerpendicularFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestSlopeFunction · 0.68