Exemplo n.º 1
0
// Returns the unit vector from a, and it's magnitude
func (a *Point) Normalize() (Point, float32) {
	mag := math.Sqrt(a.X*a.X + a.Y*a.Y)
	unit := Point{a.X / mag, a.Y / mag}

	return unit, mag
}
Exemplo n.º 2
0
// Returns the squared euclidean distance from a point to a line *segment*
func (l *Line) PointDistance(point Point) float32 {
	return math.Sqrt(l.PointDistanceSquared(point))
}
Exemplo n.º 3
0
func (p *Point) PointDistance(p2 Point) float32 {
	return math.Sqrt(p.PointDistanceSquared(p2))
}