• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

i finish building the fuction but in certain cases..

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it works in all cases exept
when i tried to rotate the point (0,1) around the point (0,0)
180 degrees clock wise instead of giving me the value(0,-1)

it gives me

6.123233995736766E-17,-1.0

when i tried to rotate the point (0,1) around the point (0,0)
270 degrees clock wise instead of giving me the value(-1,0)

it gives me

-1.0,-1.2246467991473532E-16

when i tried to rotate the point (0,1) around the point (0,0)
0 degrees clock wise instead of giving me the value(0,1)

it gives me
6.123233995736766E-17,1.0

i dont know what this E number means
i dont know why it happening??


public void rotate(Point center,double angle)
{
double xi; //represents the temprary values of x (the rotated point) befoure we add the values of the center point
double yi; //represents the temprary values of y (the rotated point) befoure we add the values of the center point
double rad;
xi=0;
yi=0;
rad=0;

rad=distance(center);
double fi;
fi=0;

double beta;
beta=0;
rad=distance(center);

angle=(angle/180)*PI;

double slope;

slope=(y-center.y)/(x-center.x);

fi=atan(slope);

beta=fi-angle;




xi=rad*cos(beta);
yi=rad*sin(beta);
x=center.x+xi;

y=center.y+yi;





}//end rotate
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "E" signifies "times 10 to the Nth power", also known as scientific notation

So "6.123233995736766E-17" means 6.123233995736766 * 10^-17, which is something around 0.00000000000000006123233995736766. For your purposes you can probably just round off those numbers to the desired significance -maybe 10 digits- and the result will be zero.

As to why those numbers aren't exactly zero to begin with, have a look at #20 in the http://faq.javaranch.com/java/JavaBeginnersFaq.

[EJFH: Fix URL]
[ December 21, 2007: Message edited by: Ernest Friedman-Hill ]
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well done. You appear to be doing a lot better than yesterday.

As Ulf Dittmer has told you, if you draw those figures on a graph, you won't see a difference between 0 and 6.123233995736766E-17!
 
We must storm this mad man's lab and destroy his villanous bomb! Are you with me tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic