Trigonometry [message #256577] |
Sat, 17 May 2008 03:42 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: loandbt.bigpond.com
Hello,
I am just trying Eclipse after using NetBeans. I copied over a project
which was faultless in NetBeans but presents all sorts of problems in
Eclipse, mainly with maths, and especially trigonometry.
Even though I import java.lang.math which has all the functions covered I
find I have to put Math.cos(some double) but now I have run up against a
wall as I get this error: 'The method cos(double) is undefined for the
type SunCls' SunCls referring to SunCls.java.
I have defined the pertinent double as a double and the method cos is
defined in java.lang.math so I don't know how to define a method
cos(double) and can't understand the error at all.
Would it be correct to say that Eclipse cannot handle trigonometry?
|
|
|
|
Re: Trigonometry [message #256589 is a reply to message #256577] |
Sat, 17 May 2008 06:41 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: groups.pellaton.li
Hi
First of all, Eclipse can handle every java library/program. My guess is
that your NetBeans and Eclipse use different JVMs. Could you please
provide the following information:
a) the operating system you are using
b) the version of Eclipse you are using
Help > About
c) the version of Java SDK you are using
in a shell/command line type: java -version
d) the version of Java SDK your projects is configured to use
Project > Properties > Java Build Path > Tab Libraries:
JRE System Library
e) Is SunCls a class you wrote? It seems not to be a Class of the JRE.
HTH
Michael
Barry Jaques wrote:
> Hello,
>
> I am just trying Eclipse after using NetBeans. I copied over a project
> which was faultless in NetBeans but presents all sorts of problems in
> Eclipse, mainly with maths, and especially trigonometry.
>
> Even though I import java.lang.math which has all the functions covered I
> find I have to put Math.cos(some double) but now I have run up against a
> wall as I get this error: 'The method cos(double) is undefined for the
> type SunCls' SunCls referring to SunCls.java.
>
> I have defined the pertinent double as a double and the method cos is
> defined in java.lang.math so I don't know how to define a method
> cos(double) and can't understand the error at all.
>
> Would it be correct to say that Eclipse cannot handle trigonometry?
>
|
|
|
Re: Trigonometry [message #256604 is a reply to message #256589] |
Sat, 17 May 2008 09:11 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: loandbt.bigpond.com
Many thanks for the comments. Here is some of my code:
import java.lang.Math.*;
import java.util.Calendar;
public class SunCls {
//declare variables here.......
double mLongitude;
double mLatitude;
double mAltitude;.....etc
int mDayOfYear;;.....etc
public SunCls(int Day, int Month, int Year, double ASThr,
double Longitude, double Latitude, double Altitude) {
mDayOfMonth = Day;
mMonth = Month;
mYear = Year;
mASTHr = ASThr;
mLongitude = Longitude;
mLatitude = Latitude;
mAltitude = Altitude;
UpToDate = false;
}
public void ReCalc() {
Calendar mDate = Calendar.getInstance() ;
mDate.set(mYear, mMonth, mDayOfMonth);
mDayOfYear = mDate.get(Calendar.DAY_OF_YEAR);
// Ioext is solar radiation at top of atmosphere --
// it is based on the solar constant corrected for earth to sun distance
Offending line ->> mIoext = Isc * (1.0 + 0.033 * Math.cos((360.0 *
(double)mDayOfYear / 370.0) * RadPerDeg));
// Declination -- The apparent tilt of the earths axis of rotation to
the ecliptic
// +23.45 at summer solstice, -23.45 at winter solstice, and 0 at
the equinoxes
// returns declination for the day of year in radians
Offending line ->> mDeclination = RadPerDeg * 23.45 *
Math.sin(((mDayOfYear - 80.0) / 370.0) * 360.0 * RadPerDeg);
// Hour Angle --
// found by taking the time between solar noon and current AST, and
// multiplying by 15 deg/hr, then converting to radians.
mHrAng = (mASTHr - 12.0) * (360.0 / 24.0) * RadPerDeg;
// Altitude Angle -- the solar altitude in radians
Offending line ->> mAltAng = Math.cos(mLatitude);
Offending line ->> mAltAng = Math.asin(Math.cos(mLatitude) *
Math.cos(mDeclination)
Offending line ->> * Math.cos(mHrAng) + Math.sin(mLatitude) *
Math.sin(mDeclination));
}
In the offendine line mDayOfYear has red underline and when I hover over
it with the mouse I get the error the method cos(double) is undefined for
the type SunCls.
I am at a loss as to what type SunCls means but there is nothing wrong
with the code as far as I can see. However if I do it in two steps like
this the error dissappears.
mIoext = Math.cos((360.0 * (double)mDayOfYear / 370.0) * RadPerDeg);
mIoext = Isc * (1.0 + 0.033 * mIoext);
I am on Windows Vista Ultimate, Eclipse 3.2.2, Java(TM) SE Runtime
Environment (build 1.6.0_05-b13),
JDK Compliance 6.0, Project JRE System Library [jre1.6.0_05]
My original question now re Eclipse handling trigonometry now seems
incorrect. It seems there is something incorrect with the particular line
of code.
|
|
|
|
Re: Trigonometry [message #256616 is a reply to message #256612] |
Sat, 17 May 2008 10:18 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: loandbt.bigpond.com
Hi Felix, Don't you ever go home? I went for a walk and fixed up some
plumbing on the coffee machine for a break.
Anyway I have to say I'm very sorry about this problem. There was a red
underline under the doubles on each offending line but I think I was
taking that error message too serious. I think it was just a red herrring
as it had nothing to do with anything. Once I broke up that first line and
rebuilt the project all the errors on the suubsequent lines dissappeared.
The only other thing I did was to comment out the unnecessary imports. I
did not know about not having to import. One import I still need to use is
calendar but that is in another class. However the strange thing is that
if I now uncomment the first offending line it now works. So its been a
terrible day. I should read a bit more of the book.
Thanks for the help.
|
|
|
|
Powered by
FUDForum. Page generated in 0.08875 seconds