Skip to content

Azimuth errato #22

Description

@jumpjack

Math.atan2(sH, cH * slat - (sdec / cdec) * clat), // Azimuth - (13.5) p. 93

Come da commento presente nel codice stesso, il valore di azimuth restituito è errato, in quanto calcolato rispetto al sud, mentre la convenzione lo vuole calcolato rispetto al nord; forse conviene aggiungere un'opzione per specificare quale convenzione usare.

io ho fatto così:

	eqToHz: function(eqcoord, eclCoord, strad, typeOfAzimuth)  { // ADDED OPTION FO FIX AZIMUTH
		var H = strad - eclCoord.lng - eqcoord.ra; // ra = Right Ascension (alpha)
		
		var sH = Math.sin(H); // H = hour angle
		var cH = Math.cos(H);
		var slat = Math.sin(eclCoord.lat);         // lat = latitude (phi)
		var clat = Math.cos(eclCoord.lat);
		var sdec = Math.sin(eqcoord.dec);          // dec = declination (delta)
		var cdec = Math.cos(eqcoord.dec);

//// FIX AZIMUTH:
		var addAz = 0;
		
		if (typeof typeOfAzimuth !== 'undefined') {
			if((typeOfAzimuth==="N")||(typeOfAzimuth==="n")) {
				addAz=Math.PI;
			} else {
				addAz=0;
			}
		}	
////
		return new A.HzCoord(
			// Meeus citation:
			// "If one wishes to reckon the azimuth from the North instead of the South,
			// add 180 degrees to the first value"
			Math.atan2(sH, cH * slat - (sdec / cdec) * clat) + addAz,    //  Azimuth  - (13.5) p. 93 
			Math.asin(slat * sdec + clat * cdec * cH)            //  Altitude - (13.6) p. 93
		);
	}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions