Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Trigonometry
Trigonometry [message #256577] Sat, 17 May 2008 03:42 Go to next message
Eclipse UserFriend
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 #256585 is a reply to message #256577] Sat, 17 May 2008 06:33 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
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?
>
Eclipse is not in 5th grade :-p

1) Importing "java.lang.Math" doesn't help/do anything. The "java.lang" package
is imported automatically. You can refer to all classes in this package without
importing it.

2) About your error. Sure you write (capitalized) Math.cos(1.234)? If you do
math.cos(123.23) and math is of type SunCls, you'd get that error. Even if you
declared a variable "Math" of that type, I think that error would persist. Post
your code (in fragments) if you continue to have problems.


Felix
Re: Trigonometry [message #256589 is a reply to message #256577] Sat, 17 May 2008 06:41 Go to previous messageGo to next message
Eclipse UserFriend
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 messageGo to next message
Eclipse UserFriend
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 #256612 is a reply to message #256604] Sat, 17 May 2008 09:43 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
The line compiles fine here..

double Isc=0, RadPerDeg=4, mIoext = .5d;
int mDayOfYear = 4;
mIoext = Isc * (1.0 + 0.033 * Math.cos((360.0 * (double)mDayOfYear / 370.0) *
RadPerDeg));

You could post your class with out the introduced comments.
Re: Trigonometry [message #256616 is a reply to message #256612] Sat, 17 May 2008 10:18 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Trigonometry [message #256619 is a reply to message #256616] Sat, 17 May 2008 11:15 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
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
Previous Topic:JLabel reference
Next Topic:Does a plug-in-project have to be a java-project?
Goto Forum:
  


Current Time: Wed Jul 17 17:20:44 GMT 2024

Powered by FUDForum. Page generated in 0.08503 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top