self
and other
as trigonometric ratioBehave similarly to the toplevel atan2
as it returns the angle in the appropriate quadrant.
var p0 = new Point[Float](0.0, 0.0)
var p1 = new Point[Float](1.0, 1.0)
assert p0.atan2(p1).is_approx(0.25*pi, 0.0001)
# Arctangent function using the difference between `self` and `other` as trigonometric ratio
#
# Behave similarly to the toplevel `atan2` as it returns the angle in the appropriate quadrant.
#
# ~~~
# var p0 = new Point[Float](0.0, 0.0)
# var p1 = new Point[Float](1.0, 1.0)
# assert p0.atan2(p1).is_approx(0.25*pi, 0.0001)
# ~~~
fun atan2(other: Point[N]): Float
do
var dx = other.x.to_f - x.to_f
var dy = other.y.to_f - y.to_f
return sys.atan2(dy.to_f, dx.to_f)
end
lib/geometry/angles.nit:21,2--35,4