Creating a MATLAB GUI for Geometry in Two and Three Dimensions
By Putra Chheang
Fall 2015
In Partial Fulfillment of
MATH 4395 ̶ Senior Project
Department of Mathematics and Statistics
University of Houston-Downtown
Faculty Advisor:
Dr. Timothy Redl
Committee Member:
Dr. Edwin Tecarro
Committee Member:
Dr. Rebecca Quander
Department Chair:
Dr. Shishen Xie
1
TABLE OF CONTENTS
Abstract ______________________________________________________________________2
Acknowledgements _____________________________________________________________3
List of Figures ________________________________________________________________4
Introduction __________________________________________________________________6
History ___________________________________________________________________________ 6
Motivation ________________________________________________________________________ 7
Purpose __________________________________________________________________________ 7
Geometric Calculator _______________________________________________________________ 8
Two Dimensional Figures _______________________________________________________9 Square _________________________________________________________________________________ 10 Rectangle _______________________________________________________________________________ 11 Trapezoid _______________________________________________________________________________ 12 Rhombus _______________________________________________________________________________ 14 Parallelogram ____________________________________________________________________________ 15 Triangle ________________________________________________________________________________ 17 Regular Polygon _________________________________________________________________________ 18 Circle __________________________________________________________________________________ 20 Ellipse _________________________________________________________________________________ 20 Sector of a Circle _________________________________________________________________________ 21 Segment of a Circle _______________________________________________________________________ 22
Three Dimensional Figures _____________________________________________________24 Prism __________________________________________________________________________________ 24
Square Base _________________________________________________________________________ 25 Rectangle Base _______________________________________________________________________ 25 Isosceles Trapezoid Base _______________________________________________________________ 26 Rhombus Base _______________________________________________________________________ 28 Parallelogram Base ___________________________________________________________________ 29 Triangle Base ________________________________________________________________________ 31 Regular Polygon Base _________________________________________________________________ 34
Pyramid ________________________________________________________________________________ 35 Circular Cylinder ________________________________________________________________________ 36 Circular Cone ___________________________________________________________________________ 37 Sphere _________________________________________________________________________________ 38
An Application of the Geometric Calculator _______________________________________39
Conclusion __________________________________________________________________40
Future Work _________________________________________________________________41
References __________________________________________________________________42
2
Abstract
Suppose that a student is doing homework for a Math course that involves calculating the
area and perimeter of a geometric figure; for example, the area and perimeter of a Rhombus.
Some students not only want to know if their answers are correct, they may want to define what
a Rhombus is. What does it look like? And what are its properties? This program will be a useful
tool for them to verify the answer as well as giving them the definition along with a drawing of
the figure. In addition, the formulas will also be included for some students who might not
remember them.
This program is called Geometric Calculator. It contains various types of common
geometric shapes in both two dimensions and three dimensions. For 2 dimensional figures, there
are square, rectangle, trapezoid, rhombus, parallelogram, triangle, regular polygon, circle,
ellipse, sector of a circle, and segment of a circle. The 3 dimensional figures included are: prism
classified by various bases, pyramid with regular polygon base, right circular cylinder, right
circular cone, and sphere.
For some particular geometric figures, the solution can be found using more than one
method; and also, the given inputs can be different. For example, to find the area of a Rhombus,
the user will be asked to give either two diagonals or an angle with a side length. So, this
program is very challenging. MATLAB is the main vehicle of this project since it contains so
many mathematical functions and the special feature to plot any geometric figures.
3
Acknowledgement
I would like to especially thank my advisor Dr. Timothy Redl for assisting me throughout
the entire project. His contribution is sincerely appreciated and gratefully acknowledged.
Without his help, I would not be able to accomplish this project as well as learn so much about
the capability of the MATLAB program. I would also like to acknowledge both of my committee
members, Dr. Edwin Tecarro and Dr. Rebecca Quander for their time and supports. I would also
like to thank my professor, Dr. Linda Becerra, who helped me through my tough time and
pushed me to become a better student. I would also like to thank Dr. Sergiy Koshkin who has
given me so much knowledge about the history of Mathematics. Last but not least, I would like
to thank my classmates, especially, William Bui who inspires me to learn even more about
geometry and gives me opinion about my project.
4
List of Figures
Figure 1: Main Windows _______________________________________________________________________ 8
Figure 2: Two dimensional shape _________________________________________________________________ 9
Figure 1-1: Square ___________________________________________________________________________ 10
Figure 1-2: Rectangle _________________________________________________________________________ 11
Figure 1-3A: Trapezoid _______________________________________________________________________ 12
Figure 1-3B: Isosceles Trapezoid ________________________________________________________________ 13
Figure 1-4A: Option 1 with given two diagonal _____________________________________________________ 14
Figure 1-4B: Option 2 with an angle and a side length _______________________________________________ 15
Figure 1-5A: Area of parallelogram ______________________________________________________________ 16
Figure 1-5B: Perimeter of a parallelogram _________________________________________________________ 16
Figure 1-6A: Area of a triangle _________________________________________________________________ 17
Figure 1-6B: Perimeter of isosceles triangle ________________________________________________________ 18
Figure 1-7A: Regular polygon __________________________________________________________________ 19
Figure 1-7B: Method 1 for area of regular polygon __________________________________________________ 19
Figure 1-8: Circle ____________________________________________________________________________ 20
Figure 1-9: Ellipse ___________________________________________________________________________ 21
Figure 1-10: Sector of a circle __________________________________________________________________ 22
Figure 1-11: Segment of a circle ________________________________________________________________ 23
Figure 3: Three dimensional shapes ______________________________________________________________ 24
Figure 2-1: Bases of prism _____________________________________________________________________ 24
Figure 2-1-1: Prism with square base _____________________________________________________________ 25
Figure 2-1-2: Prism with rectangle base ___________________________________________________________ 26
Figure 2-1-3A: Prism with isosceles trapezoid base __________________________________________________ 27
Figure 2-1-3B: A property of isosceles trapezoid is not met ___________________________________________ 27
Figure 2-1-4A: Prism with a rhombus base ________________________________________________________ 28
Figure 2-1-4B: Rhombus base prism is a square base prism ___________________________________________ 29
5
Figure 2-1-5A: Volume of a prism with parallelogram base ___________________________________________ 30
Figure 2-1-5B: Surface area of a prism with parallelogram base ________________________________________ 30
Figure 2-1-6A: Prism with scalene triangle base ____________________________________________________ 31
Figure 2-1-6B: Prism with isosceles triangle base ___________________________________________________ 32
Figure 2-1-6C: Prism with equilateral triangle base __________________________________________________ 33
Figure 2-1-7: Prism with regular polygon base _____________________________________________________ 34
Figure 2-2: Pyramid with regular polygon base _____________________________________________________ 36
Figure 2-3: Circular cylinder ___________________________________________________________________ 37
Figure 2-4: Circular cone ______________________________________________________________________ 37
Figure 2-5: Sphere ___________________________________________________________________________ 38
Figure 4: An application of geometric calculator ____________________________________________________ 39
6
Introduction
History
Geometry has a known history dating from the times of the ancient Egyptians and
Babylonians 4000 years ago through the seminal work of the Greek geometer Euclid (~265-325
BCE) and up to the present day. The world itself originates in two Greek words: geo, meaning
“Earth,” and metron, meaning “measure.” Geometry originated as a practical science, used for
measuring distances. With Euclid, geometry began its evolution toward a more theoretical
approach. In addition to that, trigonometry also plays a big role in mathematics. Trigonometry
developed from a need to compute distances and angle measures, especially in map making,
surveying, and range finding for artillery use. Today, trigonometry is an indispensable tool in
many applied problems in both science and technology. The word trigonometry is derived from
the Greek words trigonom, which means “triangle,” and metron, which means “measurement.”
When we go back in time, Hipparchus of Nicea (180-125 BCE) is sometimes called the father of
trigonometry because he is one of the first to try and organize a set of values associating arcs and
chords of a circle. This work helped those who came later in the development of modern notions
of trigonometry.
From knowing that the world is not flat, to measurement between planets, to
measurement between cells, to Mandelbrot’s work with fractals, geometry has changed as our
knowledge base has expanded. In schools, too, geometry has changed. We no longer consider
geometry as consisting solely of theorems and proofs; we no longer consider geometry in
isolation from the rest of mathematics.
7
Motivation
Mathematics has always been my favorite subject since I was in the middle school, and
geometry is my strongest subject among mathematics. This is why I decided to pursue my degree
in Mathematics. Also, I am very interested in Computer Science which is why I declared it as my
minor.
I had always worried about my senior project because I had no idea which project I
should choose until the semester of Spring 2015, which I took Computational Mathematics, and
Geometry for Teachers with Dr. Timothy Redl and Dr. Rebecca Quander, respectively. After
taking both classes which involved the study of Geometry and the study of MATLAB
application, which is useful for solving mathematical problems as well as plotting graphs, I
became more interested in learning about this software and expanding my knowledge of
geometry to create this project. However, without Dr. Redl, I would not know how to combine
these 2 subjects in order to develop this project.
Purpose
The purpose of this project is to create MATLAB GUI application for the computational
mathematics in geometry. MATLAB can be used to write code, modify and implement just like
other programming languages such as C++, Visual Basic and Java. In addition, this application is
capable of plotting figures in both two and three dimensions. This is why I choose MATLAB for
my project.
8
Geometric Calculator
Geometric Calculator is a program developed entirely using MATLAB software. The
built-in Graphical User Interface (GUI) is very simple to use which allows me to basically drag
and drop whichever I need such as textbox, label, button, drop down menu, and axes for the plot.
This program is developed with a simple user interface where the users can easily
navigate to the option they prefer. As shown in Figure 1, the Main Windows contains two
buttons and two drop down menus. If the user clicks 2 Dimensions button, the ‘Select a 2D
figure’ menu will be visible. Similarly, the ‘Select a 3D figure’ menu will become visible once
the user clicks 3 Dimensions button. The Exit button is also included so that the user can simply
exit the program along with a message box in case the user accidentally clicks the Exit button.
Figure 1: Main windows
9
1. Two Dimensional Figure
In 2 dimensional figure mode, the program will calculate the area, perimeter, and
circumference of the geometric figures such as square, rectangle, trapezoid, rhombus,
parallelogram, triangle, regular polygon, circle, ellipse, sector of a circle and segment of a circle
as shown in Figure 2.
Figure 2: Two dimensional shapes
10
1.1 Square
Definition
A square is a quadrilateral with four right angles and four congruent sides (Equivalently,
a square is a rectangle with two adjacent sides congruent.)
The program will prompt a user to input a side length as shown in Figure 1-1. Since a
side length of a square is always a positive number strictly greater than 0, so if the user enters a
‘0’ or negative number, the program will show an error message asking the user to correct the
input number.
Let ‘s’ be denoted as a side length of a square. Then,
Area of a square 𝐴𝐴 = 𝑠𝑠2
Perimeter of a square 𝑃𝑃 = 4 × 𝑠𝑠
Figure 1-1: Square
11
1.2 Rectangle
Definition
A rectangle is a parallelogram with a right angle. (Equivalently, a rectangle is a
quadrilateral with four right angles.)
To find the area of a rectangle, the user will be asked to enter a width and a length as
shown in Figure 1-2. If the user inputs the width greater than the length, the program will show a
message box asking a user to either ‘correct’ the error or ‘close’ the windows.
Let ‘l’ be a length and ‘w’ be a width of a rectangle. Then,
Area of a rectangle 𝐴𝐴 = 𝑤𝑤 × 𝑙𝑙
Perimeter of a rectangle 𝑃𝑃 = 2 𝑤𝑤 + 2 𝑙𝑙
Figure 1-2: Rectangle
12
1.3 Trapezoid
Definition
A trapezoid is a quadrilateral with at least one pair of parallel sides. If there is exactly
one pair of congruent sides, it is called isosceles trapezoid. (Equivalently, an isosceles trapezoid
is a trapezoid with two congruent base angles.)
For this particular geometric figure, user can choose to calculate either Area or Perimeter
by clicking the buttons as shown in Figure 1-3A. If the user chooses to calculate the area, the
program will ask user to input two bases, and a height of trapezoid that is perpendicular to the
bases. Now let ‘b1 and b2’ be bases and ‘h’ be the height of the trapezoid. Then,
Area of a trapezoid 𝐴𝐴 = �𝑏𝑏1+𝑏𝑏2�ℎ2
Figure 1-3A: Trapezoid
13
If a button ‘Calculate Perimeter’ is selected, the panel ‘Perimeter of a Trapezoid’ will
become visible, and the user will be prompted to enter two bases and two side lengths as the
perimeter of a trapezoid is the sum of bases and side lengths. In case the user inputs 2 congruent
side lengths, a trapezoid is specifically named isosceles trapezoid; the red message will be
visible telling the user that it is an isosceles trapezoid as shown in Figure 1-3B.
Let ‘b1and b2’ be bases and ‘s1 and s2’ be side lengths.
Then, perimeter of a trapezoid is:
𝑃𝑃 = 𝑏𝑏1 + 𝑏𝑏2 + 𝑠𝑠1 + 𝑠𝑠2
Figure 1-3B: Isosceles trapezoid
14
1.4 Rhombus
Definition
A rhombus is a parallelogram with two adjacent sides congruent (Equivalently, a
rhombus is a quadrilateral with all sides congruent). In addition, two non-congruent diagonals
are perpendicular and bisect each other.
Area and perimeter of a rhombus can be found by using two different given input options
as shown in Figure 1-4A. First option, the area can be solved with given two diagonals ‘d1 &
d2’, and another option is given a side length ‘s’ and an angle θ.
Option 1: both diagonals are given:
Area of a rhombus:
𝐴𝐴 = 𝑑𝑑1 × 𝑑𝑑22
Since the side length is not given,
we can find it by using Pythagorean
Formula.
𝑆𝑆 =�(𝑑𝑑1)2+ (𝑑𝑑2)2
2
Once we find a side length, then
the perimeter can be easily solved by the following formula:
𝑃𝑃 = 4 × 𝑆𝑆
Figure 1-4A: Option 1 with given two diagonals
15
Option 2: an angle θ and a side length S are given:
Since a side length is given, the
perimeter of a rhombus can be easily
found using the same formula in option 1.
However, to calculate the area, d1 & d2
need to be solved first in order to apply the
area formula.
𝑑𝑑1 =2𝑆𝑆sin 𝜃𝜃2
2
𝑑𝑑2 =2𝑆𝑆cos 𝜃𝜃2
2
After solving for diagonals, we can solve for the area using the area formula in option 1.
The Figure 1-4B shows how the program calculates the area and perimeter of a rhombus.
1.5 Parallelogram
Definition
A parallelogram is a quadrilateral in which each pair of opposite sides is parallel.
For a parallelogram calculation, this program will let the user choose between finding the
area and the perimeter. If the user chooses to calculate the area of a parallelogram, the base b and
the height h will be needed as shown in Figure 1-5A.
The area formula of a parallelogram is: 𝐴𝐴 = 𝑏𝑏 × ℎ
Figure 1-4B: Option 2 with an angle and a side length
16
In order to calculate perimeter, the user will need to enter base length b and side length s.
Perimeter of a parallelogram is:
𝑃𝑃 = 2𝑏𝑏 + 2ℎ
Figure 1-5B shows that the panel
Perimeter of Parallelogram and
the button Area becomes visible.
Figure 1-5A: Area of parallelogram
Figure 1-5B: Perimeter of a parallelogram
17
1.6 Triangle
Definition
A Triangle is a plane figure with three straight sides and three angles. There are several
types of triangles such as scalene triangle, isosceles triangle and equilateral triangle.
In the Triangle windows, the user will have the options to choose either to calculate the
area or perimeter.
For the area calculation, the
program will need the user to input
a base b and a height h as shown in
Figure 1-6A.
Area of a Triangle is:
𝐴𝐴 = 𝑏𝑏 × ℎ2
If the user clicks on the
button Perimeter, the panel
Perimeter of Triangle will become
visible, and three inputs will be required. All side lengths s1,s2 and s3 can be entered in any
order. However, if the values of any two sides are equal, the triangle becomes an isosceles
triangle, and the red message will be visible as shown in Figure 1-6B; similarly, if the user
enters all equal side lengths, the red message will be shown to tell the user that it is an
equilateral triangle, and the title is also changed.
Figure 1-6A: Area of a triangle
18
Yet, the program will check
if the user enters the valid input
that would not against the Triangle
inequality theorem which states
that ‘the sum of the lengths of any
two sides of a triangle is greater
than the length of the third side.’ If
the inputs are invalid, the error
message will be shown, and the
user can correct the error. So, the
formula of perimeter of a triangle
is: 𝑃𝑃 = 𝑠𝑠1 + 𝑠𝑠2 + 𝑠𝑠3
1.7 Regular Polygon
Definition
A Polygon in which all the interior angles are congruent and all the sides are congruent is
regular polygon.
The number of side lengths classifies a regular polygon. For example, if a polygon has
5,6,7 and 8 sides, it is called pentagon, hexagon, heptagon and octagon, respectively.
For this particular geometric shape, the area and perimeter can be computed by using two
different methods with the same inputs, number of sides n and a side length s. Figure 1-7A
shows the 2 different formulas for the area of a polygon; Method 1 and Method 2 buttons are
both visible for a user to click the method he or she prefers.
Figure 1-6B: Perimeter of isosceles triangle
19
If the Method 1 is selected, the
panel method 1 will be visible as well as
the formula for the area and perimeter.
As stated above, the number of
sides classifies the regular polygon, so if
the user inputs n = 5, the program will plot
a figure based on the input number as
shown in Figure 1-7B.
For both methods, the formula for
a perimeter of regular polygon is the same.
Perimeter of a regular polygon is: 𝑃𝑃 = 𝑛𝑛 × 𝑠𝑠
The following are formulas for the area of a regular polygon in two different methods.
Method 1:
𝐴𝐴 = 𝑛𝑛 𝑠𝑠2
4 tan (90 − 180𝑛𝑛 )
Method 2:
𝐴𝐴 = 𝑛𝑛 × 𝑠𝑠 × 𝑎𝑎2
Where ‘a’ is the Apothem
𝑎𝑎 = 𝑠𝑠2 tan (180
𝑛𝑛 )
Figure 1-7A: Regular polygon
Figure 1-7B: Method 1 for area of regular polygon
20
1.8 Circle
Definition
A circle is a round plane figure whose boundary (the circumference) consists of points
equidistant from a fixed point (the center).
For a circle, the only input required
to calculate the area and circumference is a
radius r as shown in Figure 1-8.
Area of a circle is:
𝐴𝐴 = 𝜋𝜋𝑟𝑟2
Circumference of a circle is:
𝐶𝐶 = 2𝜋𝜋𝑟𝑟
1.9 Ellipse
Definition
An ellipse is a curve on a plane surrounding two focal points such that the sum of the
distances to the two focal points is constant for every point on the curve.
Solving the area of an ellipse is similar to solving the area of a circle. However, instead
of a single radius, an ellipse needs two radii r1 & r2 as shown in Figure 1-9.
Figure 1-8: Circle
21
Area of an ellipse is:
𝐴𝐴 = 𝜋𝜋 × 𝑟𝑟1 × 𝑟𝑟2
Circumference of an ellipse
𝐶𝐶 = 2𝜋𝜋�𝑟𝑟12+𝑟𝑟22
2
1.10 Sector of a Circle
Definition
A sector of a circle is a pie-shaped region of the circle determined by an angle whose
vertex is the center of the circle. This angle is a central angle. The area of a sector depends on
the radius of the circle and the measure of the central angle determining the sector. If the angle
has a measure of 90o, as in Figure 1-10, the area of the sector is one-fourth the area of the circle.
To determine the area of a sector of a circle, a radius r and a center angle 𝜃𝜃 are required.
In addition to solving for the area, the program also computes an arc length of a circle.
Figure 1-9: Ellipse
22
Area of a sector of a circle is:
𝐴𝐴 = 𝜋𝜋𝑟𝑟2 𝜃𝜃360
Arc length of a circle is:
𝑆𝑆 = 𝜋𝜋𝑟𝑟 𝜃𝜃180
1.11 Segment of a Circle
Definition
The segment of a circle is the region bounded by a chord and the arc subtended by the
chord. Note that, its central angle is always less than 1800, and neither the radius nor the center
point is included in the segment.
To find a segment of a circle, the program needs the user to input a radius r and an angle
𝜃𝜃. As stated above, for example, if the user inputs 𝜃𝜃 = 2700, the program will identifies the error
and show a message box stating that the angle has to be strictly greater than 00 and strictly less
than 1800. Also, the plot corresponds to angle the user enters as shown in the Figure 1-11.
Figure 1-10: Sector of a circle
23
There is no specific
formula to find the area of a
segment of a circle, yet we can
solve for it by using the area of a
sector minus the area of triangle.
Area of sector is: 𝜋𝜋𝑟𝑟2 𝜃𝜃360
Area of triangle is: 12𝑟𝑟2𝑠𝑠𝑠𝑠𝑛𝑛𝜃𝜃
Area of Segment of a circle is:
𝐴𝐴 = 𝑟𝑟2( 𝜋𝜋𝜃𝜃360−12 𝑠𝑠𝑠𝑠𝑛𝑛𝜃𝜃)
Figure 1-11: Segment of a circle
24
2. Three Dimensional Figure
As shown in Figure 3, the program will calculate the volume and the surface area of the
3-dimensional figures such as Prism, Pyramid, Circular Cylinder, Circular Cone and Sphere.
2.1 Prism
A prism is a polyhedron in which two
congruent faces lie in parallel planes and the other faces
are bounded by rectangles. The prism can be classified
according to their bases, and it is usually named after its
bases, for example a triangular right prism. The faces
other than the bases are the lateral faces of the prism.
Figure 3: Three dimensional shapes
Figure 2-1: Bases of prism
25
2.1.1 Prism with Square Base
For the square base prism, the
program will ask a user to enter the side
length s and the height of the prism h.
Notice that the prism will become
a cube if s = h, and the red message will
be visible to inform the user.
Volume of a square base prism
𝑉𝑉 = 𝐴𝐴ℎ
Where ‘A’ is the area of a square
As shown in Figure 2-1-1, adding all the area of the six faces can calculate the surface
area of a prism. Since we can find the area of bases using the above formula, we will only need
to find the area of the four lateral faces. The perimeter of the square multiplied by the height h is
equal to the sum of 4 lateral faces.
Surface area of a square base prism denoted by SA is: 𝑆𝑆𝐴𝐴 = 4𝑠𝑠ℎ + 2𝑠𝑠2
2.1.2 Prism with Rectangular Base
For this prism, finding the volume and surface area are similar to the prism with square
base; however, instead of a side length, the program will ask a user to enter two positive numbers
for width w and length l as shown in Figure 2-1-2. Moreover, the program checks if l > w in
order to meet a property of a rectangle that is the length has to be strictly greater than the width.
Figure 2-1-1: Prism with square base
26
Volume of a rectangle base prism
is:
𝑉𝑉 = 𝑤𝑤 × 𝑙𝑙 × ℎ
The surface area of this prism is:
𝑆𝑆𝐴𝐴 = 2(𝑤𝑤ℎ + 𝑙𝑙ℎ + 𝑤𝑤𝑙𝑙)
2.1.3 Prism with Isosceles Trapezoid Base
In this particular prism, the base is limited to be an isosceles trapezoid base. Therefore, to
calculate the volume and surface area, users will be asked to enter four inputs, which are two
bases b1 & b2, side length s and the height of the prism h.
Since the base is an isosceles trapezoid, the height of isosceles trapezoid denoted as a can
be solved using Pythagorean Formula as shown in Figure 2-1-3A. Even thought the bases of
an isosceles trapezoid can be entered with any positive numbers, the users have to make sure that
base lengths have to be different, otherwise, an error message box will pop up showing that the
inputs do not meet a property of an isosceles trapezoid as shown in Figure 2-1-3B.
Figure 2-1-2: Prism with rectangle base
27
Volume of isosceles trapezoid base
prism:
𝑉𝑉 = 𝐴𝐴ℎ
Where ‘A’ is the area of the base
𝐴𝐴 = 𝑎𝑎(𝑏𝑏1+𝑏𝑏22 )
And ‘a’ is the height of the
trapezoid
𝑎𝑎 = �𝑠𝑠2 −𝑙𝑙𝑙𝑙𝑛𝑛𝑙𝑙 𝑏𝑏𝑎𝑎𝑠𝑠𝑏𝑏 − 𝑠𝑠ℎ𝑙𝑙𝑟𝑟𝑜𝑜 𝑏𝑏𝑎𝑎𝑠𝑠𝑏𝑏
2
Surface area of the prism is:
𝑆𝑆𝐴𝐴 = 𝑃𝑃ℎ + 2𝐴𝐴
Where ‘P’ is perimeter of the base
𝑃𝑃 = 𝑏𝑏1 + 𝑏𝑏2 + 2𝑠𝑠
Figure 2-1-3A: Prism with isosceles trapezoid base
Figure 2-1-3B: A property of isosceles trapezoid is not met
28
2.1.4 Prism with Rhombus Base
For the prism with a rhombus base, the program will need 3 inputs d1 & d2, diagonals of
the Rhombus, and the height h of the prism as shown in Figure 2-1-4A.
If we look closely to the
properties of a rhombus, a rhombus
is a parallelogram that has 4
congruent side lengths, and its
diagonals are perpendicular and
bisect each other. So, as long as the
input numbers are positive
numbers, the program will
calculate both volume and surface
area. However, if the users input
equal values of both diagonals, the
program will show a red message
telling that the rhombus is a square
as shown in Figure 2-1-4B.
Volume of a prism with rhombus base is:
𝑉𝑉 = 𝐴𝐴ℎ where ‘A’ is the area of a rhombus
𝐴𝐴 = 𝑑𝑑1+𝑑𝑑22
Figure 2-1-4A: Prism with a rhombus base
29
Surface area of the prism is:
𝑆𝑆𝐴𝐴 = 𝑃𝑃ℎ + 2𝐴𝐴
Where ‘P’ is the perimeter of the
base
𝑃𝑃 = 4𝑠𝑠
And ‘s’ is the side length of a
rhombus, which can be solve using
Pythagorean formula
𝑠𝑠 =�(𝑑𝑑1)2+ (𝑑𝑑2)2
2
2.1.5 Prism with Parallelogram Base
The prism with parallelogram base calculator requires a user to choose between
calculating volume and surface area by clicking either a buttons Volume or Surface Area as
shown in Figure 2-1-5A. To calculate the volume of this particular prism, the program needs 3
inputs: the long side of parallelogram b, height of parallelogram a perpendicular to the b, and the
height of the prism h. As always, all inputs have to be positive numbers strictly greater than 0;
otherwise, a message box will pop up telling the user the inputs are invalid.
Figure 2-1-4B: Rhombus base prism is a square base prism
30
Volume of this prism is:
𝑉𝑉 = 𝐴𝐴ℎ
Where ‘A’ is the area of
parallelogram
𝐴𝐴 = 𝑏𝑏 × 𝑎𝑎
For the surface area of a
prism with parallelogram base, a
side length s of a parallelogram is
needed in addition to the inputs required to calculate the volume. Notice that, s is always greater
than a, which is the height of the parallelogram perpendicular to b. Figure 2-1-5B shows how the
program calculates the surface area of the prism with parallelogram base.
Surface Area is:
𝑆𝑆𝐴𝐴 = 𝑃𝑃ℎ + 2𝐴𝐴
Where ‘P’ is the perimeter of the
base
𝑃𝑃 = 2(𝑏𝑏 + 𝑠𝑠)
Figure 2-1-5A: Volume of a prism with parallelogram base
Figure 2-1-5B: Surface area of a prism with parallelogram base
31
2.1.6 Prism with Triangle Base
A triangular base prism is the most challenging among the various types of prisms. User
will have 3 options to choose: scalene triangle, isosceles triangle, and equilateral triangle.
The definition of a particular triangle will be shown as soon as the user clicks the appropriate
button, and the panel of the formulas and denotation will be titled corresponding to its specific
type of triangle.
Scalene Triangle base prism
A scalene triangle is a triangle with three non-congruent side lengths.
In this particular triangle, the program will ask a user to enter 5 required inputs as shown
in Figure 2-1-6A. The user should be careful with the height a of a scalene triangle as it has to
be perpendicular to the base b and less than its side lengths s1 & s2. Therefore, the volume of the
prism is calculated as followed:
𝑉𝑉 = 𝐴𝐴ℎ
Where ‘A’ is the area of a triangle
𝐴𝐴 = 𝑏𝑏 × 𝑎𝑎2
Surface Area of the prism is:
𝑆𝑆𝐴𝐴 = 𝑃𝑃ℎ + 2𝐴𝐴
Where 𝑃𝑃 = 𝑏𝑏 + 𝑠𝑠1 + 𝑠𝑠2
Figure 2-1-6A: Prism with scalene triangle base
32
Isosceles Triangle base prism
An isosceles triangle is a triangle with two congruent side lengths.
The volume and surface area of this specific triangle require a user to input the base b of
a triangle, side length s, the height of the prism denoted as h as shown in Figure 2-1-6B.
In addition to calculate the volume and surface area, the program also calculate the height
of an isosceles triangle using Pythagorean formula.
Volume of the prism: 𝑉𝑉 = 𝐴𝐴ℎ , where ‘A’ is the area of triangle 𝐴𝐴 = 𝑏𝑏 × 𝑎𝑎2
Surface Area of the prism: 𝑆𝑆𝐴𝐴 = 𝑃𝑃ℎ + 2𝐴𝐴, where ‘P’ is perimeter of triangle 𝑃𝑃 = 2𝑠𝑠 + 𝑏𝑏
Figure 2-1-6B: Prism with isosceles triangle base
33
Equilateral Triangle base prism
Equilateral triangle is a triangle in which all 3 sides are congruent.
The only inputs the program requires in order to calculate the volume and surface area of
equilateral triangle base prism are a side length s of the base and the height h of the prism as
shown in Figure 2-1-6C. So, the following are the formulas to calculate the volume and surface
area:
Volume of the prism: 𝑉𝑉 = 𝐴𝐴ℎ
Where 𝐴𝐴 = 𝑠𝑠 × 𝑎𝑎2
And ‘a’ is the height of the equilateral triangle, which we can solve using Pythagorean formula.
𝑎𝑎 = �𝑠𝑠2 − (𝑠𝑠2)2
Surface area of the prism:
𝑆𝑆𝐴𝐴 = 𝑃𝑃ℎ + 2𝐴𝐴
Where ‘P’ is the perimeter of the
base
𝑃𝑃 = 3𝑠𝑠
Figure 2-1-6C: Prism with equilateral triangle base
34
2.1.7 Prism with Regular Polygon Base
A Regular Polygonal base prism is a prism with the base in which all sides are congruent.
It is pretty straightforward to calculate the volume and surface area of the prism with
regular polygon base. The user will need to input 3 positive numbers greater than 0.
Here, n is denoted as the
number of sides of the base, s is the
side length of the base, and h is the
height of the prism.
The program will draw a
figure that corresponds to the
number of sides of the regular
polygon, and as shown in Figure
2-1-7, a title is given to the figure
base on the standard name of the
polygon such as Prism with
Hexagon base.
Volume of the prism is: 𝑉𝑉 = 𝐴𝐴ℎ
Where ‘A’ is the area of the base 𝐴𝐴 = 𝑛𝑛 𝑠𝑠2
4 tan (90 − 180𝑛𝑛 )
Surface area of the prism is: 𝑆𝑆𝐴𝐴 = 𝑃𝑃ℎ + 2𝐴𝐴
Where ‘P’ is the perimeter of the base: 𝑃𝑃 = 𝑛𝑛 × 𝑠𝑠
Figure 2-1-7: Prism with regular polygon base
35
2.2 Pyramid with Regular Polygon Base
Definition
A pyramid is a polyhedron determined by a polygon and a point not in the plane of the
polygon. The pyramid consists of the triangular regions determined by the point and each pair of
consecutive vertices of the polygon and the polygonal region determined by the polygon. The
polygonal region is the base of the pyramid, and the point is the apex. As with a prism, the faces
other than the base are lateral faces. Pyramids are classified according to their bases, for
example a square base pyramid or a pentagonal pyramid.
The required inputs to calculate volume and surface area for a pyramid with regular
polygon base are similar to the prism with regular polygon base. The number of side n, the side
length s, and the height of the prism h are needed as shown in Figure 2-2.
Once the user clicks the button Calculate, the program draws a figure that corresponds to
the number of sides the user inputs, and the title is given based on the number of sides as well.
Volume of a pyramid with regular polygon base is:
𝑉𝑉 = 13𝐴𝐴ℎ
Where ‘A’ is the area of the base
𝐴𝐴 = 𝑛𝑛 𝑠𝑠2
4 tan (90 − 180𝑛𝑛 )
Surface Area of the pyramid is:
𝑆𝑆𝐴𝐴 = 2𝜋𝜋𝑟𝑟2 + 𝜋𝜋𝑟𝑟ℎ
36
2.3 Circular Cylinder
Definition
A circular cylinder is a cylinder with circular bases and with the axis joining the two
centers of the bases perpendicular to the planes of the two bases.
For a circular cylinder, the program will ask a user to input the radius r of the circular
base and the height h of the cylinder. In addition to calculating for the volume in cubic units, the
program also calculates the volume in term of 𝜋𝜋 as shown in Figure 2-3.
Figure 2-2: Pyramid with regular polygon base
37
Volume of a circular cylinder:
𝑉𝑉 = 𝜋𝜋𝑟𝑟2ℎ
Surface area of a circular cylinder:
𝑆𝑆𝐴𝐴 = 2(𝜋𝜋𝑟𝑟2 + 𝜋𝜋𝑟𝑟ℎ)
2.4 Circular Cone
Definition
A cone is the union of line
segments connecting point P to each point
on a circular plane. Point P is the vertex of
the cone. A line segment from vertex P
perpendicular to the center point of a
circular plane of the base is the altitude
(the height of a cone).
Figure 2-3: Circular Cylinder
Figure 2-4: Circular Cone
38
To solve for the volume and surface area of a circular cone, the program requires a user
to provide 2 inputs that are the radius r of a circular base and the height h of the cone. The
volume in term of 𝜋𝜋 is also calculated as shown in Figure 2-4.
Volume of a circular cone is:
𝑉𝑉 = 13𝜋𝜋𝑟𝑟2ℎ
Surface area of a circular cone is:
𝑆𝑆𝐴𝐴 = 𝜋𝜋𝑟𝑟(𝑟𝑟 + √ℎ2 + 𝑟𝑟2)
2.5 Sphere
Definition
A Sphere is a three dimensional figure consisting of a set of points equidistant from a
central point.
The only input required is the
radius r of the sphere.
Volume of a sphere is:
𝑉𝑉 = 43𝜋𝜋𝑟𝑟
3
Surface Area of a sphere is:
𝑆𝑆𝐴𝐴 = 4𝜋𝜋𝑟𝑟2
Figure 2-5: Sphere
39
An Application of Geometric Calculator
In Figure 10, MATLAB generates a plot that contains four subplots showing how the
surface area and volume are changed if either the radius or the height is fixed. For example, the
top right corner subplot shows a graph of how the volume of a cylinder is changed when the
radius r=1 unit is fixed and the height is increasing from 1 to 40 units.
Figure 4: An application of Geometric Calculator
40
Conclusion
Geometric Calculator is a major project I have done so far; and it is very challenging.
Throughout the project, I have done much research about MATLAB software in order to
accomplish it in addition to my knowledge of understanding geometry. Talking about geometry,
there is so much more to learn about the details and properties for each geometry shape.
Mistakes can be easily made if one does not pay attention to details.
Before I started the project, I was so worried how I could accomplish such a major
project that I have never done before. However, with the helps of my advisor and committee
members, I have exceeded my expectations, which I am very proud of what I have invested with
all my time and work.
This program is being built with a very simple user interface so that the users can easily
navigate to the section they would like to calculate. In addition to this, colors are added to the
buttons and labels in order to make the program even easier to use and also attract the users
attention. Once the project is completed, I hope that it will become not only a handy calculator
for mathematics courses but also a teaching tool for students who want to learn more about
geometry as well as MATLAB program.
41
Future Work
After I completed this project, I realized that the program I developed has a potential that
could be expanded to make it even better. Throughout the coding process, I have come across so
many errors that I would have never thought of. However, this has taught me how to identify the
errors and correct them so that I can improve this program in the future. Also, I would like to
modify Geometric Calculator to increase its functionalities, which gives users the flexibility of
entering different inputs and solving various problems.
Since the time is limited, this program contains just a portion of geometry. There are
many more complicated geometric figures that I would like to include in the future such as
oblique prism, oblique cylinder, oblique cone, convex polyhedron, concave polyhedron,
octahedron, icosahedron and dodecahedron.
In addition, the majority of people now carry smartphones, which they use daily no
matter where they go, and hundreds of thousands of mobile applications are now available for
them to download and use. However, I have done some research and found out that there are
small numbers of mobile applications for mathematics field, especially the calculator for
geometry. Therefore, for my future project, I would like to make Geometric Calculator a
mobile platform for both Android OS and Apple iOS.
42
References
1. Billstein, Rick, Shlomo Libeskind, and Johnny W. Lott. A Problem Solving Approach to
Mathematics for Elementary School Teachers. 9th ed. Boston: Pearson Addison Wesley,
2007. Print.
2. "Documentation." Graphics. The MathWorks, n.d. Web. 06 Dec. 2015.
<http://www.mathworks.com/help/matlab/graphics.html>.
3. "Parallelogram - Math Word Definition - Math Open Reference." Parallelogram - Math
Word Definition - Math Open Reference. Math Open Reference, n.d. Web. 06 Dec. 2015.
<http://www.mathopenref.com/parallelogram.html>.
4. Jain, Mohnish. "Electroposium." : PLOTTING 3D GRAPHS USING MATLAB.
Blogspot.com, 21 Feb. 2013. Web. 06 Dec. 2015. <http://symposium-
eng.blogspot.com/2013/02/plotting-3d-graphs-using-matlab.html>.
5. Simmons, Bruce. "Mathwords: Area of a Regular Polygon." Mathwords: Area of a Regular
Polygon. Mathwords, 28 July 2014. Web. 06 Dec. 2015.
<http://www.mathwords.com/a/area_regular_polygon.htm>.
6. "Circle Sector and Segment." Http://www.mathsisfun.com/geometry/circle-sector-
segment.html. MathsIsFun, n.d. Web. 6 Dec. 2015.
<http://www.mathsisfun.com/geometry/circle-sector-segment.html>.
7. "Regular Polygon." Wikipedia. Wikimedia Foundation, 23 Nov. 2015. Web. 06 Dec. 2015.
<https://en.wikipedia.org/wiki/Regular_polygon>.
8. "Segment of a Circle." Segment of a Circle. MathCaptian.com, 2015. Web. 06 Dec. 2015.
<http://www.mathcaptain.com/geometry/segment-of-a-circle.html>.
43