swing - Does Java have the Pythagoras Theorem? -


i use java swing create simple games such pong , air hockey, , find myself using pythagoras theorem calculate distance between 2 points.

although it's not pain write (it can reduced single line), wondering if java had included somewhere.

i looked through math class, , didn't see there. didn't know else look, if exist, know where?

thanks!

yes, java has such function in standard library. called math.hypot. can write:

math.hypot(x2 - x1, y2 - y1) 

this method part of java since java 1.5.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -