ID:2948789
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
Basically, this computes the distance between the origin and a point (x, y) on the Euclidean plane.
Equivalently, compute the length of the hypotenuse of a right-angle triangle with other sides having length x.abs() and y.abs().

Most other languages have this.

This would help with everything from distance calculations, to colors, to physics simulations, and more. Especially if implemented in a performance-friendly way.
This really helps with float precision issues with values we're just going to sqrt anyways.

It's basically (minus some float memes):
/proc/hypot(x, y)
var/xx = abs(x)
var/yy = abs(y)

var/rat = yy / xx
return xx * sqrt(1 + rat*rat)


Calling directly into hypotf would probably be best.

Login to reply.