Пример #1
0
// Angle return the Atan2 between dx/dy where dx and dy are given by p2 - p. In other words, you get the direction from
// p to p2 in a cartesial cooridinate system with 0 angles.
func (p Point) Angle(p2 Point) angular.Angle {
	dx := float64(p2.X - p.X)
	dy := float64(p2.Y - p.Y)
	return angular.Atan2(dy, dx).Normalize()
}
Пример #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
}