| | |
The problem with using Java's maths.cos()
![]() |
There are two things which I didn't or could not achieve with using maths.cos() from Java.
First - When I calculate cos90 or cos270, it gives me absurb values. It should be 0. Meaning it cannot calculate if the angle lies on X axis.
I tested with 91 or 271, gives a near 0 which is correct.
Second - I was figuring how do I include the number of terms to be calculated with my Cosine formula....
Lastly, I am using JFrames as my GUI and I can only properly exit from my menu bar. And not from the X button at top RH corner.
I would appreciate hints or guidance in solving the above 3 issues. Thank you so much people!
First - When I calculate cos90 or cos270, it gives me absurb values. It should be 0. Meaning it cannot calculate if the angle lies on X axis.
I tested with 91 or 271, gives a near 0 which is correct.
Second - I was figuring how do I include the number of terms to be calculated with my Cosine formula....
Lastly, I am using JFrames as my GUI and I can only properly exit from my menu bar. And not from the X button at top RH corner.
I would appreciate hints or guidance in solving the above 3 issues. Thank you so much people!
If you properly set up the application you can exit the application normally (with JVM shutdown) by using the operating system supplied features (like the close icon in the window corner) as well.
Something like in your main application frame should work wonders.
Something like
Java Syntax (Toggle Plain Text)
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
42
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
Hi eveyone,
Use loops and arrays
Richard West
•
•
•
•
Originally Posted by LiBOC
Second - I was figuring how do I include the number of terms to be calculated with my Cosine formula
Richard West
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
Yea, I had convert it into radians before putting it back into the default math.cos() method... but only 270 and 90 are wrong values!
•
•
•
•
Originally Posted by dandan
Math.cos is using angles in radians. Try Math.cos(Math.toRadians(90)).
Second - I don't understand.
Try jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Thanks.
I used the calculator program on my WinXP to counter check with my Java App. It is exactly correct. Only for 90 and 270 degrees. I also had converted them to radians.
And also, math.cos() method do not include terms if I am not wrong?
What if I want to write my own cosine formula that include a user-defined number of terms? Rewrite the formula into a java language? Solve the maths equation yourself?
can math.cos() do that?
I used the calculator program on my WinXP to counter check with my Java App. It is exactly correct. Only for 90 and 270 degrees. I also had converted them to radians.
And also, math.cos() method do not include terms if I am not wrong?
What if I want to write my own cosine formula that include a user-defined number of terms? Rewrite the formula into a java language? Solve the maths equation yourself?
can math.cos() do that?
•
•
•
•
Originally Posted by jwenting
no, the rest is wrong as well (though it is possible that by some chance a few distinct values might happen to be identical it's unlikely).
But they're less obviously wrong unless you know what to expect. Do you know the exact cosine of every angle to 10 decimal places without looking them up?
•
•
•
•
What if I want to write my own cosine formula that include a user-defined number of terms? Rewrite the formula into a java language? Solve the maths equation yourself?
•
•
•
•
1/2cos x =75
•
•
•
•
1/2cos(3x) -5cos = 45
*Voted best profile in the world*
![]() |
Other Threads in the Java Forum
- Previous Thread: help
- Next Thread: error when compiling
Views: 11709 | Replies: 27
| Thread Tools | Search this Thread |
Tag cloud for Java
access android api apple applet application arguments array arrays automation binary c++ chat class classes client code combobox compiler component converter coordinates data database db design detection draw eclipse error event exception fast file fractal game givemetehcodez graphics gridlayout gui helpwithhomework html ide image inheritance input integer interface j2me java jni jpanel jtable jtextfield julia linux list loop map method methods mobile netbeans newbie number object objects oracle os pattern phone pixel print problem program programming project read recursion regex remote remove robot scanner screen search server set size sms socket string swing test text threads timer transfer tree windows






