Section calculates the Point that divides a line in specific ratio. DO NOT specify the ratio in the form m:n, specify it as r, where r = m / n.
(p1, p2 *Point, r float64)
| 22 | // Section calculates the Point that divides a line in specific ratio. |
| 23 | // DO NOT specify the ratio in the form m:n, specify it as r, where r = m / n. |
| 24 | func Section(p1, p2 *Point, r float64) Point { |
| 25 | var point Point |
| 26 | point.X = (r*p2.X + p1.X) / (r + 1) |
| 27 | point.Y = (r*p2.Y + p1.Y) / (r + 1) |
| 28 | return point |
| 29 | } |
| 30 | |
| 31 | // Slope calculates the slope (gradient) of a line. |
| 32 | func Slope(l *Line) float64 { |