geometry

package
v0.0.0-...-a4a72b7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package geometry contains geometric algorithms

Package geometry contains geometric algorithms

Index

Constants

This section is empty.

Variables

View Source
var ErrDimMismatch = errors.New("mismatched dimensions")

Functions

func Distance

func Distance(a, b *Point) float64

Distance calculates the shortest distance between two points.

func EuclideanDistance

func EuclideanDistance(p1 EuclideanPoint, p2 EuclideanPoint) (float64, error)

EuclideanDistance returns the Euclidean distance between points in any `n` dimensional Euclidean space.

func IsParallel

func IsParallel(l1, l2 *Line) bool

IsParallel checks if two lines are parallel or not.

func IsPerpendicular

func IsPerpendicular(l1, l2 *Line) bool

IsPerpendicular checks if two lines are perpendicular or not.

func PointDistance

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

PointDistance 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

Slope calculates the slope (gradient) of a line.

func YIntercept

func YIntercept(p *Point, slope float64) float64

YIntercept calculates the Y-Intercept of a line from a specific Point.

Types

type EuclideanPoint

type EuclideanPoint []float64

EuclideanPoint defines a point with x and y coordinates.

type Line

type Line struct {
	P1, P2 Point
}

type Point

type Point struct {
	X, Y float64
}

Point defines a point with x and y coordinates.

func Section

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

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.

Jump to

Keyboard shortcuts

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