geometry

package
v0.0.3-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance

func Distance(a, b *Point) float64

Calculates the shortest distance between two points.

func Intercept

func Intercept(p *Point, slope float64) float64

Calculates the Y-Intercept of a line from a specific Point.

func IsParallel

func IsParallel(l1, l2 *Line) bool

Checks if two lines are parallel or not.

func IsPerpendicular

func IsPerpendicular(l1, l2 *Line) bool

Checks if two lines are perpendicular or not.

func PointDistance

func PointDistance(p *Point, equation [3]float64) float64

Calculates the distance of a given Point from a given line. The slice should contain the coefficiet of x, the coefficient of y and the constant in the respective order.

func Slope

func Slope(l *Line) float64

Calculates the slope (gradient) of a line.

Types

type Line

type Line struct {
	P1, P2 Point
}

type Point

type Point struct {
	X, Y float64
}

Defines a point with x and y coordinates.

func Section

func Section(p1, p2 *Point, r float64) Point

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL