Exemplo n.º 1
0
// Distance returns the linear distance between p and p2.
func (p Point) Distance(p2 Point) linear.Distance {
	dx := p2.X - p.X
	dy := p2.Y - p.Y
	return linear.Hypot(dx, dy)
}
Exemplo n.º 2
0
// Polar returns the polar representation of p.
func (p Point) Polar() (linear.Distance, angular.Angle) {
	r := linear.Hypot(p.X, p.Y)
	phi := angular.Atan2(float64(p.Y), float64(p.X)).Normalize()
	return r, phi
}