Skip to content

Instantly share code, notes, and snippets.

@olcayertas
Last active April 25, 2017 00:58
Show Gist options
  • Save olcayertas/686d8b6f47962fe97fb3 to your computer and use it in GitHub Desktop.
Save olcayertas/686d8b6f47962fe97fb3 to your computer and use it in GitHub Desktop.
Calculates qibla angel acording to curren location.
private static final double KAABA_LONGITUDE = 39.826228;
private static final double KAABA_LATITUDE = 21.422305;
private double getQiblaAngele(double myLatitude, double myLongitude) {
double sinMyLoMinusQLo = Math.sin(myLongitude - KAABA_LONGITUDE);
double cosMyLat = Math.cos(myLatitude);
double tanQLat = Math.tan(KAABA_LATITUDE);
double sinMyLat = Math.sin(myLatitude);
double cosMyLoMinusQlo = Math.cos(myLongitude - KAABA_LONGITUDE);
double result = Math.atan(sinMyLoMinusQLo / cosMyLat * tanQLat - sinMyLat * cosMyLoMinusQlo);
return Math.toDegrees(result);
}
@ahmadmust8
Copy link

there is a lot of maths operation ?
what dose the getQiblaAngele method exactly returns.
thanks for publish this code (;

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