Last change
on this file since 345 was 127, checked in by Wouter Pasman, 6 years ago |
#41 ROLL BACK of rev.126 . So this version is equal to rev. 125
|
File size:
441 bytes
|
Line | |
---|
1 | package agents.Jama.util;
|
---|
2 |
|
---|
3 | public class Maths {
|
---|
4 |
|
---|
5 | /** sqrt(a^2 + b^2) without under/overflow. **/
|
---|
6 |
|
---|
7 | public static double hypot(double a, double b) {
|
---|
8 | double r;
|
---|
9 | if (Math.abs(a) > Math.abs(b)) {
|
---|
10 | r = b/a;
|
---|
11 | r = Math.abs(a)*Math.sqrt(1+r*r);
|
---|
12 | } else if (b != 0) {
|
---|
13 | r = a/b;
|
---|
14 | r = Math.abs(b)*Math.sqrt(1+r*r);
|
---|
15 | } else {
|
---|
16 | r = 0.0;
|
---|
17 | }
|
---|
18 | return r;
|
---|
19 | }
|
---|
20 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.