Thread View: borland.public.jbuilder.java.api
3 messages
3 total messages
Started by Felipe
Tue, 16 Dec 2003 04:16
Math problem please help me
Author: Felipe
Date: Tue, 16 Dec 2003 04:16
Date: Tue, 16 Dec 2003 04:16
71 lines
2538 bytes
2538 bytes
hi...im working with jbuilder and i have a problem with Math class.... i write my class but in the teta2 angle send me an NaN i was checking but i cant found the problem... somebody can help me??? is urgent..this is my class
import java.math.*;
import java.util.*;
import java.lang.*;
import java.text.*;
public class Cinversa {
public Cinversa(String coordx,String coordy) {
double B;
double x,y;
double r;
double r2, x2, y2, teta1, teta2, L1, L2, t, L12, L22;
double Beta, Gama, G, fi, fi2, rad1, rad2;
int largo;
String X3 =coordx;
String Y3 = coordy;
x = Double.valueOf(coordx).doubleValue();
y = Double.valueOf(coordy).doubleValue();
if (y != 0) {
L1 = 62.5;
L2 = 53;
System.out.println(x);
System.out.println(y);
x2 = Math.pow(x,2);
y2 = Math.pow(y,2);
r2 = (x2+y2);
r = Math.sqrt(r2);
System.out.println(r2);
G = (r2 + Math.pow(L1,2) - Math.pow(L2,2))/(2*L1*r);
System.out.println(G);
Gama = Math.acos(G);
System.out.println("gama");
B = y/x;
System.out.println(B);
Beta = Math.atan(B);
System.out.println(Beta);
fi = (r2 - Math.pow(L1,2) - Math.pow(L2,2))/(2*L1*L2);
System.out.println(fi);
System.out.println("fi");
teta2 = Math.acos(fi);*******here is the problem***********
System.out.println(teta2);
System.out.println("teta2");
if (teta2 > 0) {
teta1 = (Beta - Gama);
t = (teta1 *625)/1450;
System.out.println(teta1);
}
if (teta2 < 0) {
teta1 = (Beta + Gama);
t = (teta1 *625)/1450;
System.out.println(teta1);
}
}
}
}
Re: Math problem please help me
Author: kc
Date: Tue, 16 Dec 2003 08:17
Date: Tue, 16 Dec 2003 08:17
89 lines
3175 bytes
3175 bytes
What values are using.
I used 12.4 and 14.1
and get the following
12.4
14.1
352.57000000000005
0.6177053966874066
gama
1.1370967741935483
0.849461322392921
-0.9604045283018868
fi
2.859246884862765
teta2
-0.05551347883261104
Felipe wrote:
> hi...im working with jbuilder and i have a problem with Math class.... i write my class but in the teta2 angle send me an NaN i was checking but i cant found the problem... somebody can help me??? is urgent..this is my class
>
>
> import java.math.*;
> import java.util.*;
> import java.lang.*;
> import java.text.*;
>
> public class Cinversa {
>
> public Cinversa(String coordx,String coordy) {
> double B;
> double x,y;
> double r;
>
> double r2, x2, y2, teta1, teta2, L1, L2, t, L12, L22;
> double Beta, Gama, G, fi, fi2, rad1, rad2;
> int largo;
>
> String X3 =coordx;
> String Y3 = coordy;
>
> x = Double.valueOf(coordx).doubleValue();
> y = Double.valueOf(coordy).doubleValue();
>
>
> if (y != 0) {
> L1 = 62.5;
> L2 = 53;
> System.out.println(x);
> System.out.println(y);
> x2 = Math.pow(x,2);
> y2 = Math.pow(y,2);
> r2 = (x2+y2);
> r = Math.sqrt(r2);
> System.out.println(r2);
>
> G = (r2 + Math.pow(L1,2) - Math.pow(L2,2))/(2*L1*r);
> System.out.println(G);
> Gama = Math.acos(G);
> System.out.println("gama");
> B = y/x;
> System.out.println(B);
> Beta = Math.atan(B);
> System.out.println(Beta);
>
>
> fi = (r2 - Math.pow(L1,2) - Math.pow(L2,2))/(2*L1*L2);
> System.out.println(fi);
> System.out.println("fi");
> teta2 = Math.acos(fi);*******here is the problem***********
> System.out.println(teta2);
> System.out.println("teta2");
>
>
> if (teta2 > 0) {
>
> teta1 = (Beta - Gama);
> t = (teta1 *625)/1450;
> System.out.println(teta1);
> }
>
> if (teta2 < 0) {
>
> teta1 = (Beta + Gama);
> t = (teta1 *625)/1450;
> System.out.println(teta1);
> }
> }
> }
> }
Re: Math problem please help me
Author: Felipe
Date: Tue, 16 Dec 2003 14:21
Date: Tue, 16 Dec 2003 14:21
4 lines
1169 bytes
1169 bytes
thank u KC it was the problem.... the range of the values... its working
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads