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++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -