Trigonometry [message #256577] |
Fri, 16 May 2008 23:42  |
Eclipse User |
|
|
|
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 #256604 is a reply to message #256589] |
Sat, 17 May 2008 05:11   |
Eclipse User |
|
|
|
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 #256619 is a reply to message #256616] |
Sat, 17 May 2008 07:15  |
Eclipse User |
|
|
|
Barry Jaques wrote:
> Hi Felix, Don't you ever go home?
Unfortunately I _am_ at home... I live where I work or I work where I live,
don't know which is true..
Good that you solved your problems.
Felix
|
|
|
Powered by
FUDForum. Page generated in 0.08082 seconds