The Qibla direction angle is the angle that you need to face in order to pray towards the Kaaba in Mecca. You can use a physical compass or a compass app.

Simply align the needle or the on-screen arrow with magnetic north, and then turn your body until you're facing the correct angle as indicated by our calculation related to your city.

If you're using a physical compass, you may need to adjust for local magnetic declination, which is the difference between magnetic north and true north. This information can usually be found on maps or online. **Calculation Method**

- Define the coordinates of Mecca, Saudi Arabia:
- Convert the latitude and longitude of the user's location and Mecca to radians:
- Calculate the difference in longitude and latitude between the two points:
- Calculate the qibla direction using the Haversine formula:
- Normalize the qibla direction to a value between 0 and 360 degrees:

const meccaLatitude=21.4225;

const meccaLongitude=39.8262;

const lat1=latitude * (Math.PI / 180);

const lon1=longitude * (Math.PI / 180);

const lat2=meccaLatitude * (Math.PI / 180);

const lon2=meccaLongitude * (Math.PI / 180);

const dLon=lon2 - lon1;

const dLat=lat2 - lat1;

const y=Math.sin(dLon) * Math.cos(lat2);

const x=Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);

const qibla=Math.atan2(y, x) * (180 / Math.PI);

const qiblaNormalized=(qibla + 360) % 360;