averbraeck / opentrafficsim

Open Source Multi-Level Traffic Simulator
BSD 3-Clause "New" or "Revised" License
28 stars 8 forks source link

Replace Math.sqrt(dx*dx + dy*dy) with Math.hypot(dx, dy) #76

Closed WJSchakel closed 1 year ago

WJSchakel commented 1 year ago

Math.hypot(dx, dy) prevents overflow or underflow. It is quite slower than a direct Math.sqrt(dx*dx + dy*dy), but in OTS this is never used in performance critical code. Usages are: