🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #430

Math problem please help me

#430
From: Felipe
Date: Tue, 16 Dec 2003 04:16
71 lines
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);
     }
  }
}
}
Technical Details
Message-ID: <3fde951d@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,55e04f84d88b5035,start
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2003-12-15 21:16:29 PST
From: "Felipe" <ringostar@universia.cl>
Sender: "Felipe" <ringostar@universia.cl>
Reply-To: "Felipe" <ringostar@universia.cl>
Subject: Math problem please help me
Newsgroups: borland.public.jbuilder.java.api
X-User-Info: 158.251.2.13     
X-Forwarded-For: 158.251.8.183
NNTP-Posting-Host: 207.105.83.66
Message-ID: <3fde951d@newsgroups.borland.com>
Date: 15 Dec 2003 21:16:13 -0700
X-Trace: newsgroups.borland.com 1071551773 207.105.83.66 (15 Dec 2003 21:16:13 -0700)
Lines: 72
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!newsgroups.borland.com!not-for-mail