You are on page 1of 6

Proceedings of the 3rd IMT-GT Regional Conference on Mathematics, Statistics and Applications

Universiti Sains Malaysia


Shahrul Nizam Ishak And 2Jamaludin Md Ali
School of Mathematical Sciences, Universiti Sains Malaysia, 11800 Penang.
e-mail: 1 , 2

ABSTRACT. The problem of determining the direction of Qibla is a problem of mathematical geography. Thus, this
paper describes the mathematical calculation used in a computer programming in order to determine the direction of
Qibla. The mathematical methods used were Spherical Trigonometry and Vector Calculus. An electronic device application
is one of the convenient methods in developing a program of a system. The discussion is confined to the scientific aspects of
the subject and the religion rulings are analyzed only for an underlying scientific assumption and also for knowledge

Keywords: Qibla , Qibla Direction , Computer Approach, VCalQLator

1 Introduction
Computer programming is an implementation of computer application in developing a program. According to
GuruNet [9], computer programming is a preparation process before the computer can implement further task
required. Thus, the preparation made must be based on logic or otherwise the program will not execute
Praying (solah) five times a day as stated in the Holy Quran has been compulsory upon all mature Muslim as an
individual obligatory (fardhu ‘ain). Thus, in order to perform the prayer, basically Muslims have to learn how to
perform it by learning the law of prayer (fiqh solah) and also understand the philosophy behind the prayer itself.
However, the solah must be performed with sincere reverence and humility (khushu‘), otherwise it is considered
invalid. Solah is performed by facing to the direction of Qibla (towards the Kaabah in Makkah) until the day of
the judgment.
According to Ghazali Saad [3] stated that all of the Four-Imam in Islam community such as Imam Maliki, Imam
Hanafi, Imam Hanbali and Imam Syafie had agreed that whoever wants to perform the prayer must direct their
face and chest in the direction of the Sacred Mosque (Kaabah) in Makkah. The direction is called ‘Qibla’. Qibla
is important because it is one of a compulsory condition whenever Muslim performs their prayer. Hence, many
of the Muslim scholars have determined ways and methods regarding the Qibla direction. Therefore, this paper
will focus only on the mathematics calculation in determining the Qibla direction, which is referring to the
location of the cities that depends on its latitude and longitude.

2 Historical Overview Regarding Qibla Direction
Before, proceeding further on the calculation, it is important to know some history about the Qibla. In the early
century of Islamic development, it is not a problem to determine the Qibla since the Prophet Muhammad
himself shows the Qibla direction to his companions (Sahabah) when they were outside of Makkah area.
Regarding the determination of Qibla direction showed by the Prophet, the writer is still seeking for the
information about the techniques or methods that had been used by the Prophet Muhammad when he was
building the first few mosques in Islam such as Quba’ Mosque, the Prophet Mosque (Masjid Nabawi) in
Madinah and others. As it was known before hijrah (at Makkah) the Prophet and his companions (Sahabah) had
prayed in the Prophet Ibrahim Mosque by facing to the Kaabah as their Qibla.

Then after the hijrah from Makkah to Madinah, they have been instructed by Allah to face ‘Baitul Maqdis’
(which is situated in Palestine) when performing the five times daily prayer, which is the same Qibla direction
as the Jewish. The reason Prophet face to the Baitul Maqdis was because he wanted to attract the Jews heart to
enter into ‘Dinul-Islam’, but unfortunately, the Jews mocked the Prophet by saying :
Proceedings of the 3rd IMT-GT Regional Conference on Mathematics, Statistics and Applications
Universiti Sains Malaysia

“Muhammad membawa agama yang berlawanan dengan agama kami, tetapi berqiblat pula mengikut kami.
Kalau tidak kerana agama kami, sudah tentu baginda tidak tahu ke mana baginda hendak berqiblat”
(Adapted from Ahmad Mustafa al-Maraghiy [2])

The Prophet and his followers faced to the Baitul Maqdis for about 16 or 17 months before the Prophet
Muhammad received his new revelation. With the blessing of Allah, Allah has revealed to the Prophet to change
the Qibla from Baitul Maqdis to Kabaah as a new Qibla for all Muslim in this world and it was mentioned in the
Al-Quran [1]. Therefore, Muslims were commanded to turn towards Kaabah and starting from that moment,
Kaabah is the Qibla for the Muslim and will not be changed until the day of the hereafter and Baitul Maqdis is
the Qibla for Jews while the direction of the sun rise is the Qibla direction for the Christians.

3 Evidence On The Important to Determine Qibla Direction Accurately

i) According to Muhammad Mughniyah [4], Imam as-Syafie briefly explained that it is compulsory for
every Muslim to face towards Kaabah while performing their prayer regardless of their distance from
Kaabah. If a person is able to determine the accurate Qibla direction by himself then he or she is
expected to face towards its, otherwise it is acceptable to determine the Qibla direction using modern
approach for any Muslim who lived far away from Makkah.

ii) Ibn Rusyd [5] stated that based on Imam as-Syafie in determining the Qibla direction it must be done
accurately and with the effort. This effort is called “Ijtihad” (the extension of sharia‘ to situations
neither covered by precedent nor explicable by analogy to other laws).

iii) Imam Abi Abdullah Muhammad Idris as-Syafie [6] had given his ‘Ijtihad’ by saying that the
determination of Qibla is based on the stars (Buruj), sun, and mountain and also winds direction.

4 Computer Application

There are many types of computer application that can be used to develop programs which are user friendly and
suitable for ordinary people. Thus, as mentioned earlier, the best choice for a beginner is to use the easiest
programming language application. Hence, this paper will focus on the programming language application using
Microsoft Visual Basic 6.0 software.
The Microsoft Visual Basic 6.0, Mark Spenik, [7] was used due to a number of advantages such as:

i) The structure of the basic programming language is very simple, particularly as to the executable

ii) Built-in functions that can help reduce the steps in the programming

iii) The VB interactive development environment (IDE) has been highly optimized to support rapid
application development (“RAD”). It is particularly easy to develop graphical user interfaces and to
connect them to handler functions provided by the application.

iv) VB also provides a comprehensive interactive and context-sensitive online help system.

5 Astronomy Knowledge with Calculation
Generally, calculation can be done with the help of the computer programming in the context of astronomy.
Nowadays, there are many methods and techniques in astronomy knowledge for the determination of Qibla
direction. Each of the methods and techniques used are different in formulation and have difference level of
accuracy base on situation. Hence, a better way of implementation for this purpose is needed due to Qibla
direction actually covers by social aspect, religion aspect and also community current necessary. The
determination of Qibla direction is the most popular method currently used in Malaysia specifically, the
Spherical Trigonometric Formula.
Proceedings of the 3rd IMT-GT Regional Conference on Mathematics, Statistics and Applications
Universiti Sains Malaysia

6 Modern Approach
Since the authors write mostly in Visual Basic programming, the examples will be presented as they would by
using Microsoft Visual Basic 6. Formatting commands for Visual Basic makes it easier in the fast lane of
computer programming. They actually are similar to some of the old FORTRAN format commands with lot of
flexibility. Hopefully, it will become clear.
Basically, knowing the simple programming such as able to input variable and display answer, toolbox
recognition is good enough to use VB application. Besides, with a little skill, mathematics astronomy
formulation can be changed into simple programming language. Detailed discussion on the equations will not be
given. However, program techniques will be discussed.
Therefore, for all of the computation obtained is based on the geographical coordinate that was adapted from
Ghazali Saad [5] of Makkah, m : (21° 25′ 15.6′′ North, 39° 49′ 29.1′′ East ) and the geographical
coordinate place or point of interest that given in the Table 1.
For example: According to Smart [8] the Spherical Trigonometric Formulae,

⎡ sin λ ⎤
θ = tan

⎢ cos φ ⎥
⎣ p
tan φm − sin φ p cos λ ⎦

a = input value of latitude point of interest
b = input value of longitude point of interest
c = fixed value of latitude Makkah
d = fixed value of longitude Makkah
λ denoted as L = the different of longitude between point interest and Makkah

Is changed to:
L=b–d ; e = Sin(L) ; f = Cos(a) ; g = Tan(c) ; h = Sin(a) ; i = Cos(L)

Then, j = e / ((f * g) - (h * i))

Hence, theta = Atn(j)

Therefore, Qibla direction can be obtained by :
Qibla = ( 2*Pi – theta ) * ( 180/ pi )
Whereby the Pi / 180 is necessary because the computer run in RADIAN mode for trigonometry calculation
while astronomy computations need to calculate in DEGREE mode.
Proceedings of the 3rd IMT-GT Regional Conference on Mathematics, Statistics and Applications
Universiti Sains Malaysia

VB example:

Figure 1. Part of Spherical Trigonometry Method Programming

However, the same technique goes for the vector calculus method but the difference is in the formula used.
Basically, start with come essential constants in the General section of Visual Basic form with:

Const PI = 3.14159265
Then, make some declarations of the variables used. For instance:
Dim X1 As Double, X2 As Double

Dim a As Double, b As Double, c As Double, d As Double

Dim L As Double, p1 As Double, p2 As Double, p3 As Double

Note that all of the calculations in VB are in radian. So it is necessary in Visual Basic to convert trigonometric
calculations from radians to degrees or vice versa.
Thus, write the formula into programming language as the example in Figure 2. Note that the function-calls for
inverse cosine is :
Function Arccos(X)
X = (Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1))/rad
End Function
Hence, try to execute and add up the interface design according to individual creativity to achieve better screen
VB example:

Figure 2. Part of Vector Calculus Method Programming
Proceedings of the 3rd IMT-GT Regional Conference on Mathematics, Statistics and Applications
Universiti Sains Malaysia

Thus, Figure 3 the interface design of ‘VCalQLator’ which is base on the programming is written for attractive
appearance and also user friendly.

Figure 3. The Interface of ‘VCalQLator’

Therefore, the steps of using this ‘VCalQLator’ as follows :
i. Firstly, select your geographical location
ii. Then, automatically the latitude and longitude coordinates will appear in the latitude and
longitude boxes
iii. After that, click on the ‘calculate’ button
iv. Finally, the result of your Qibla direction and the distance of your location from Makkah will
appear in the following boxes that are “Your Azimuth Qibla is : ” and “Your Location Distance
From Makkah : ” respectively.
v. Note that a ‘Prismatic Compass’ has to be used in order to get the direction reading from the

VB example of result obtained base on the location at Acheh Mosque :

Figure 4. Result Display by using ‘VCalQLator’
Proceedings of the 3rd IMT-GT Regional Conference on Mathematics, Statistics and Applications
Universiti Sains Malaysia

Since the calculated figure for Qibla direction is obtained, a “Prismatic Compass” is needed in order to
determine the direction of Qibla base on direction reading from North according to clockwise.

7 Conclusion
In summary it can be concluded that the astronomical formulation can be determined from numerous sources.
However, calculation skill and basic knowledge besides good understanding about sciences aspect is important
and will make the development of computer programming easier and also parallel with the user need. Moreover,
whenever those aspect is fulfilled, the result obtain will be accurate. Therefore, astronomical knowledge is vital
and relevance to learn before a calculation can be made using programming language in order to make sure that
the system will run properly and useful. Last but not least, this system can be improved by developing a
geographical coordinate database for each state of Malaysia. Thus, it will benefit to all people because they can
refer their home geographical coordinate location precisely and accurately in order to determined the most
accurate Qibla direction.

8 Acknowledgements
The authors would like to extend our gratitude and greatly indebted to the School of Mathematical Sciences,
Universiti Sains Malaysia for supporting this work under its Short-term Research Grant Account No.

9 References

[1] Al-Quran: Translation by S. Abul ‘Ala Maududi (1976), The Meaning of the Quran, Islamic Publication Ltd,
Volume 1, page 115.
[2] Ahmad Mustafa al-Maraghiy (2001), Tafsir al-Maraghiy, Dewan Bahasa dan Pustaka, Kuala Lumpur, Jilid 1, page
[3] Ghazali Saad, Abdul Halim Abdul Aziz, Baharrudin Zainal, Hamzah Jaafar & Hardi Mohamad Sadali (2006), Ar-
Risalah Fi Tayin al-Qiblah, Pulau Pinang : Jabatan Mufti Negeri Pulau Pinang.
[4] Muhammad Jawad Mughniyah (1996), Fiqh Lima Mazhab, Afif Muhammad (Terjemahan), Jakarta: Penerbit
[5] Ibn Rusyd (1991), Bidayatul Mujtahid, M.A.Abdulrahman & A. Haris (Terjemahan), Kuala Lumpur, Victory
[6] Imam Abi Abdullah Muhammad Idris as-Syafie (1989), al-Umm, Jilid 1, Prof. TK. H. Ismail Yakub SH-MA
(Translation), Victory Agencie, Kuala Lumpur, Victory Agencie.
[7] Mark Spenik, Andre J. Indovia, Pierre Boutquin, David Jung (1998), Visual Basic 6.0 Interactive Course, Waite
Group Press.
[8] Smart.W.M (1977), Textbook on Spherical Astronomy, 6th Edition, Cambridge Uni. Press.
[9] GuruNet(1999-2000),[online], 22 June 2005.