I'm trying to use an overloaded constructor but keep getting an error message that says
"Can't find symbol: SunPoint(double)". I have another constructor defined with another object parameter ie. SunPoint(DateTime dt) that the compiler finds OK but it does not seem to be able to find my SunPoint(double) constructor. I am using the NetBeans IDE 5.0 to edit the code and define the constructors and have checked the code for correctness but cannot find a syntax error. Here is the code for the SunPoint class:
package ephemeris;
import ephemeris.*;
import ephemeris.conversion.*;
import java.lang.Math;
import java.lang.StrictMath;
/**
* A class representing the Sun in the sky at a paticular instant.
*
*/
public class SunPoint {
/**
* Creates a new instance of SunPoint
* @param dt A DateTime object representing an instant in time.
*/
public SunPoint(DateTime dt) {
atTime = dt;
//calc day num from J2000.0
double D = Convert.dateTimeToJD(dt) - 2451545.0;
double g = 357.529 + 0.98560028*D;
double q = 280.459 + 0.98564736*D;
//reduce to range of 0 to 360 degrees
while(g < 0 || g > 360){
if(g < 0){
g = g + 360;
} else{
g = g - 360;
}
}
while(q < 0 || q > 360){
if(q < 0){
q = q + 360;
} else{
q = q - 360;
}
}
//convert to radians
double g2 = Math.toRadians(g);
double q2 = Math.toRadians(q);
//Trig functions are static
double bb;
bb = 1.915*Math.sin(g2);
double cc;
cc = 0.02*Math.sin(2*g2);
double L = q + bb + cc;
distance = 1.00014 - 0.01671*Math.cos(g2) - 0.00014*Math.cos(2*g2);
double e = Math.toRadians(23.439 - 0.00000036*D);
L = Math.toRadians(L);
double x = Math.cos(e)*Math.sin(L);
//Find arctan by strictmath function in order to get the coorect quadrant
//convert from radians then divide answer by 15 (15 deg/hr) to get RA in hours
RA = Math.toDegrees(StrictMath.atan2(x,Math.cos(L)))/15;
if(RA < 0){
RA = RA + 24;
}
if(RA > 24 ){
RA = RA -24;
}
//Calc the Suns DECLINATION
double sin_DEC = Math.sin(e)*Math.sin(L);
DEC = Math.asin(sin_DEC);
}
private double RA;
private double DEC;
private ephemeris.DateTime atTime;
private double distance;
private double altitude;
private double azimuth;
public double getRA() {
return RA;
}
public void setRA(double RA) {
this.RA = RA;
}
public double getDEC() {
return DEC;
}
public void setDEC(double DEC) {
this.DEC = DEC;
}
public ephemeris.DateTime getAtTime() {
return atTime;
}
public void setAtTime(ephemeris.DateTime atTime) {
this.atTime = atTime;
}
public double getDistance() {
return distance;
}
public void setDistance(double distance) {
this.distance = distance;
}
public double getAltitude() {
//Certified correct 6 July 2006
double gmst = Convert.dateTimetoGMST(this.atTime);
double lmst = Convert.GMSTtoLMST(gmst);
double ra = this.getRA();
//dec in radians
double dec = Math.toRadians(this.getDEC());
//LHA in radians
double lha = Math.toRadians(Convert.getLHA(ra, this.atTime));
double Sina = Math.sin(this.DEC)*Math.sin(Convert.LATITUDE_IN_RADIANS) +
Math.cos(this.DEC)*Math.cos(Convert.LATITUDE_IN_RADIANS)*Math.cos(lha);
double altitude = Math.toDegrees(Math.asin(Sina));
this.altitude = altitude;
return altitude;
}
public void setAltitude(double altitude) {
this.altitude = altitude;
}
public double getAzimuth() {
//---------------------------------------------------------------//
double gmst = Convert.dateTimetoGMST(this.atTime);
double lmst = Convert.GMSTtoLMST(gmst);
double ra = this.getRA();
double dec = this.getDEC();
//LHA in radians
double lha = Math.toRadians(Convert.getLHA(ra, this.atTime));
double alt = this.getAltitude()*3.1415927/180;
//--------------------------------------------------------------//
//Using arctan formula: pg. 36 of Duffett-Smith
double Y = -Math.cos(dec)*Math.cos(45.25*3.1415927/180)*Math.sin(lha);
double X = Math.sin(dec) - Math.sin(45.25*3.1415927/180)*Math.sin(alt);
double TA = Y/X;
double az = 0;
az = StrictMath.atan2(Y, X);
az = Math.toDegrees(az);
if(az < 0){
az = Convert.adjust0to360(az);
}
return az;
}
public void setAzimuth(double azimuth) {
this.azimuth = azimuth;
}
public SunPoint(double jd) {
double D = jd;
double g = 357.529 + 0.98560028*D;
double q = 280.459 + 0.98564736*D;
//reduce to range of 0 to 360 degrees
while(g < 0 || g > 360){
if(g < 0){
g = g + 360;
} else{
g = g - 360;
}
}
while(q < 0 || q > 360){
if(q < 0){
q = q + 360;
} else{
q = q - 360;
}
}
//convert to radians
double g2 = Math.toRadians(g);
double q2 = Math.toRadians(q);
//Trig functions are static
double bb;
bb = 1.915*Math.sin(g2);
double cc;
cc = 0.02*Math.sin(2*g2);
double L = q + bb + cc;
distance = 1.00014 - 0.01671*Math.cos(g2) - 0.00014*Math.cos(2*g2);
double e = Math.toRadians(23.439 - 0.00000036*D);
L = Math.toRadians(L);
double x = Math.cos(e)*Math.sin(L);
//Find arctan by strictmath function in order to get the coorect quadrant
//convert from radians then divide answer by 15 (15 deg/hr) to get RA in hours
RA = Math.toDegrees(StrictMath.atan2(x,Math.cos(L)))/15;
if(RA < 0){
RA = RA + 24;
}
if(RA > 24 ){
RA = RA -24;
}
//Calc the Suns DECLINATION
double sin_DEC = Math.sin(e)*Math.sin(L);
DEC = Math.asin(sin_DEC);
}
}
The error is generated from a call to the constructor from my SunInterval class:
package sunsim;
import java.util.ArrayList;
import ephemeris.conversion.Convert;
import ephemeris.SunPoint;
import ephemeris.DateTime;
/**
*
*
*/
public class SunInterval {
/** Creates a new instance of SunInterval */
public SunInterval(ephemeris.DateTime dt1, ephemeris.DateTime dt2, double increment, String increment_type) {
jd_start = Convert.dateTimeToJD(dt1);
jd_end = Convert.dateTimeToJD(dt2);
if(increment_type.equals("DAY")){
inc = increment * 1;
}
if(increment_type.equals("HOUR")){
inc = increment * 1/24;
}
if(increment_type.equals("MINUTE")){
inc = increment * 1/(60*24);
}
if(increment_type.equals("SECOND")){
inc = increment * 1/(24*60*60);
}
//Create SunPoints at this interval of time
double st = jd_start;
SunPoint sp = null;
while(st < jd_end){
sp = new SunPoint(st);
al_sunpoint.add(sp);
st = st + inc;
}
}
private ArrayList al_sunpoint;
private double jd_start;
private double jd_end;
private double inc;
}
Any insight would be appreciated.