The document describes a C++ program called ListMyPolygons that allows users to input polygon details, store the polygon vertices in matrices, and perform transformations on the polygons. It discusses the design of the matrix, polygon, and user interface classes. The matrix class stores vertex coordinates and supports operations for transformations. Polygon classes are derived from an abstract base class and store vertex matrices. The user interface allows inputting polygons, reviewing/modifying them via transformations, and deleting polygons. While the program works for most polygons, determining regular polygons from vertices proved unreliable.
The slide of my presentation at ILC 2014 (International Lisp Conference) for the following paper that took place at the University of Montreal in August, 2014.
K. Wakita, K. Homizu, and A. Sasaki, Hygienic Macro System for JavaScript and Its Light-weight Implementation Framework, ILC '14 Proceedings of ILC 2014 on 8th International Lisp Conference, 12 pages.
The paper is available from
http://dx.doi.org/10.1145/2635648.2635653
The Framework of Image Recognition based on Modified Freeman Chain CodeCSCJournals
Image recognition of line drawing involves feature extraction and feature comparison. Works on the extraction required the representation of the image to be compared. Combining these two requirements, a framework that develops a new extraction algorithm of a chain code representation is presented. In addition, new corner detection is presented as pre-processing to the line drawing input in order to derive the chain code. This paper presents a new framework that consist of five steps namely pre-processing and image processing, new corner detection algorithm, chain code generator, feature extraction algorithm, and recognition process. Heuristic approach that is applied in the corner detection algorithm accepts input of thinned binary image and produce a modified thinned binary image consisted of J character to represent corners in the image. Using the modified thinned binary image, a new chain code scheme that is based on Freeman chain code is proposed and an algorithm is developed to generate a single chain code series that is representing the line drawing input. The feature extraction algorithm is then extracting the three pre-defined features of the chain code for recognition purpose. The features are corner properties, distance between corners, and angle from a corner to the connected corner. The explanation of steps in the framework is supported with two line drawings. The results show that the framework successfully recognizes line drawing into five categories namely not similar line drawing, and four other categories that are similar but with attributes of rotation angle and scaling ratio.
Duplicate Code Detection using Control StatementsEditor IJCATR
Code clone detection is an important area of research as reusability is a key factor in software evolution. Duplicate code degrades the design and structure of software and software qualities like readability, changeability, maintainability. Code clone increases the maintenance cost as incorrect changes in copied code may lead to more errors. In this paper we address structural code similarity detection and propose new methods to detect structural clones using structure of control statements. By structure we mean order of control statements used in the source code. We have considered two orders of control structures: (i) Sequence of control statements as it appears (ii) Execution flow of control statements.
The slide of my presentation at ILC 2014 (International Lisp Conference) for the following paper that took place at the University of Montreal in August, 2014.
K. Wakita, K. Homizu, and A. Sasaki, Hygienic Macro System for JavaScript and Its Light-weight Implementation Framework, ILC '14 Proceedings of ILC 2014 on 8th International Lisp Conference, 12 pages.
The paper is available from
http://dx.doi.org/10.1145/2635648.2635653
The Framework of Image Recognition based on Modified Freeman Chain CodeCSCJournals
Image recognition of line drawing involves feature extraction and feature comparison. Works on the extraction required the representation of the image to be compared. Combining these two requirements, a framework that develops a new extraction algorithm of a chain code representation is presented. In addition, new corner detection is presented as pre-processing to the line drawing input in order to derive the chain code. This paper presents a new framework that consist of five steps namely pre-processing and image processing, new corner detection algorithm, chain code generator, feature extraction algorithm, and recognition process. Heuristic approach that is applied in the corner detection algorithm accepts input of thinned binary image and produce a modified thinned binary image consisted of J character to represent corners in the image. Using the modified thinned binary image, a new chain code scheme that is based on Freeman chain code is proposed and an algorithm is developed to generate a single chain code series that is representing the line drawing input. The feature extraction algorithm is then extracting the three pre-defined features of the chain code for recognition purpose. The features are corner properties, distance between corners, and angle from a corner to the connected corner. The explanation of steps in the framework is supported with two line drawings. The results show that the framework successfully recognizes line drawing into five categories namely not similar line drawing, and four other categories that are similar but with attributes of rotation angle and scaling ratio.
Duplicate Code Detection using Control StatementsEditor IJCATR
Code clone detection is an important area of research as reusability is a key factor in software evolution. Duplicate code degrades the design and structure of software and software qualities like readability, changeability, maintainability. Code clone increases the maintenance cost as incorrect changes in copied code may lead to more errors. In this paper we address structural code similarity detection and propose new methods to detect structural clones using structure of control statements. By structure we mean order of control statements used in the source code. We have considered two orders of control structures: (i) Sequence of control statements as it appears (ii) Execution flow of control statements.
Face recognition using selected topographical features IJECEIAES
This paper represents a new features selection method to improve an existed feature type. Topographical (TGH) features provide large set of features by assigning each image pixel to the related feature depending on image gradient and Hessian matrix. Such type of features was handled by a proposed features selection method. A face recognition feature selector (FRFS) method is presented to inspect TGH features. FRFS depends in its main concept on linear discriminant analysis (LDA) technique, which is used in evaluating features efficiency. FRFS studies feature behavior over a dataset of images to determine the level of its performance. At the end, each feature is assigned to its related level of performance with different levels of performance over the whole image. Depending on a chosen threshold, the highest set of features is selected to be classified by SVM classifier.
Bayesian-Network-Based Algorithm Selection with High Level Representation Fee...ITIIIndustries
A real-world intelligent system consists of three basic modules: environment recognition, prediction (or estimation), and behavior planning. To obtain high quality results in these modules, high speed processing and real time adaptability on a case by case basis are required. In the environment recognition module many different algorithms and algorithm networks exist with varying performance. Thus, a mechanism that selects the best possible algorithm is required. To solve this problem we are using an algorithm selection approach to the problem of natural image understanding. This selection mechanism is based on machine learning; a bottom-up algorithm selection from real-world image features and a top-down algorithm selection using information obtained from a high level symbolic world description and algorithm suitability. The algorithm selection method iterates for each input image until the high-level description cannot be improved anymore. In this paper we present a method of iterative composition of the high level description. This step by step approach allows us to select the best result for each region of the image by evaluating all the intermediary representations and finally keep only the best one.
Text Independent Speaker Identification Using Imfcc Integrated With IcaIOSR Journals
Abstract: Over the years, more research work has been reported in literature regarding text independent
speaker identification using MFC coefficients. MFCC is one of the best methods modeled on human auditory
system. Murali et al (2011) [1] has developed a Text independent speaker identification using MFC coefficients
which follows Generalized Gaussian mixer model. MFCC, because of its filter bank structure it captures the
characteristics of information more effectively in lower frequency region than higher region, because of this,
valuable information in high frequency region may be lost. In this paper we rectify the above problem by
retrieving the information in high frequency region by inverting the Mel bank structure. The dimensionality and
dependency of above features were reduced by integrating with ICA. Here Text Independent Speaker
Identification system is developed by using Generalized Gaussian Mixer Model .By the experimentation, it was
observed that this model outperforms the earlier existing models.
Keywords: Independent Component Analysis; Generalized Gaussian Mixer Model; Inverted Mel frequency
cepstral coefficients; Bayesian classifier; EM algorithm.
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...ijaia
A support vector machine (SVM) learns the decision surface from two different classes of the input points, there are misclassifications in some of the input points in several applications. In this paper a bi-objective quadratic programming model is utilized and different feature quality measures are optimized simultaneously using the weighting method for solving our bi-objective quadratic programming problem. An important contribution will be added for the proposed bi-objective quadratic programming model by getting different efficient support vectors due to changing the weighting values. The numerical examples, give evidence of the effectiveness of the weighting parameters on reducing the misclassification between two classes of the input points. An interactive procedure will be added to identify the best compromise solution from the generated efficient solutions.
Face recognition using selected topographical features IJECEIAES
This paper represents a new features selection method to improve an existed feature type. Topographical (TGH) features provide large set of features by assigning each image pixel to the related feature depending on image gradient and Hessian matrix. Such type of features was handled by a proposed features selection method. A face recognition feature selector (FRFS) method is presented to inspect TGH features. FRFS depends in its main concept on linear discriminant analysis (LDA) technique, which is used in evaluating features efficiency. FRFS studies feature behavior over a dataset of images to determine the level of its performance. At the end, each feature is assigned to its related level of performance with different levels of performance over the whole image. Depending on a chosen threshold, the highest set of features is selected to be classified by SVM classifier.
Bayesian-Network-Based Algorithm Selection with High Level Representation Fee...ITIIIndustries
A real-world intelligent system consists of three basic modules: environment recognition, prediction (or estimation), and behavior planning. To obtain high quality results in these modules, high speed processing and real time adaptability on a case by case basis are required. In the environment recognition module many different algorithms and algorithm networks exist with varying performance. Thus, a mechanism that selects the best possible algorithm is required. To solve this problem we are using an algorithm selection approach to the problem of natural image understanding. This selection mechanism is based on machine learning; a bottom-up algorithm selection from real-world image features and a top-down algorithm selection using information obtained from a high level symbolic world description and algorithm suitability. The algorithm selection method iterates for each input image until the high-level description cannot be improved anymore. In this paper we present a method of iterative composition of the high level description. This step by step approach allows us to select the best result for each region of the image by evaluating all the intermediary representations and finally keep only the best one.
Text Independent Speaker Identification Using Imfcc Integrated With IcaIOSR Journals
Abstract: Over the years, more research work has been reported in literature regarding text independent
speaker identification using MFC coefficients. MFCC is one of the best methods modeled on human auditory
system. Murali et al (2011) [1] has developed a Text independent speaker identification using MFC coefficients
which follows Generalized Gaussian mixer model. MFCC, because of its filter bank structure it captures the
characteristics of information more effectively in lower frequency region than higher region, because of this,
valuable information in high frequency region may be lost. In this paper we rectify the above problem by
retrieving the information in high frequency region by inverting the Mel bank structure. The dimensionality and
dependency of above features were reduced by integrating with ICA. Here Text Independent Speaker
Identification system is developed by using Generalized Gaussian Mixer Model .By the experimentation, it was
observed that this model outperforms the earlier existing models.
Keywords: Independent Component Analysis; Generalized Gaussian Mixer Model; Inverted Mel frequency
cepstral coefficients; Bayesian classifier; EM algorithm.
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...ijaia
A support vector machine (SVM) learns the decision surface from two different classes of the input points, there are misclassifications in some of the input points in several applications. In this paper a bi-objective quadratic programming model is utilized and different feature quality measures are optimized simultaneously using the weighting method for solving our bi-objective quadratic programming problem. An important contribution will be added for the proposed bi-objective quadratic programming model by getting different efficient support vectors due to changing the weighting values. The numerical examples, give evidence of the effectiveness of the weighting parameters on reducing the misclassification between two classes of the input points. An interactive procedure will be added to identify the best compromise solution from the generated efficient solutions.
This is an overview of C++ (based on 1999 / 2003 standard) and its use in Object Oriented Programming. The presentation assumes that the audience knows C programming.
This Powerpoint presentation covers following topics of C Plus Plus:
Features of OOP
Classes in C++
Objects & Creating the Objects
Constructors & Destructors
Friend Functions & Classes
Static data members & functions
tybsc it sem 5 Linux administration notes of unit 1,2,3,4,5,6 version 3WE-IT TUTORIALS
Introduction: Introduction to UNIX, Linux, GNU and Linux distributions Duties of the System Administrator, The Linux System Administrator, Installing and Configuring Servers, Installing and Configuring Application Software,
Creating and Maintaining User Accounts, Backing Up and Restoring Files, Monitoring and Tuning Performance, Configuring a Secure System, Using Tools
to Monitor Security Booting and shutting down: Boot loaders-GRUB, LILO, Bootstrapping, Init
process, rc scripts, Enabling and disabling services.
The File System: Understanding the File System Structure, Working with Linux- Supported File Systems, Memory and Virtual
System Configuration Files: System wide Shell Configuration Scripts, System Environmental Settings, Network Configuration Files, Managing the init Scripts,
Configuration Tool, Editing Your Network Configuration
TCP/IP Networking: Understanding Network Classes, Setting Up a Network nterface Card (NIC), Understanding Subnetting, Working with Gateways and Routers, Configuring Dynamic Host Configuration Protocol, Configuring the Network Using the Network
The Network File System: NFS Overview, Planning an NFS Installation, Configuring an NFS Server, Configuring an NFS Client, Using Automount Services, Examining NFS Security
Connecting to Microsoft Networks: Installing Samba, Configuring the Samba Server, Creating Samba Users 3, Starting the Samba Server, Connecting to a Samba
Client, Connecting from a Windows PC to the Samba Server Additional Network Services: Configuring a Time Server, Providing a Caching Proxy Server
Internet Services: Secure Services, SSH, scp, sftp Less Secure Services (Telnet ,FTP, sync,rsh ,rlogin,finger,talk and ntalk, Linux Machine as a Server, Configuring
the xinetd Server, Comparing xinetd and Standalone, Configuring Linux Firewall Packages, Domain Name System: Understanding DNS, Understanding Types of Domain Servers, Examining Server Configuration Files, Configuring a Caching DNS Server, Configuring a Secondary Master DNS Server, Configuring a Primary
Master Server, Checking Configuration
Configuring Mail Services: Tracing the Email Delivery Process, Mail User Agent (MUA), Introducing SMTP, Configuring Sendmail, Using the Postfix Mail Server,
Serving Email with POP3 and IMAP, Maintaining Email Security Configuring FTP Services: Introducing vsftpd, Configuring vsftpd, Advanced FTP Server Configuration, Using SFTP
Configuring a Web Server: Introducing Apache, Configuring Apache, Implementing SSI, Enabling CGI, Enabling PHP, Creating a Secure Server with SSL System Administration: Administering Users and Groups Installing and Upgrading Software Packages
its a project report for theatre management project done in c++ language without graphics.h
It has welcome screen followed by a login session.
There are two login modes- User and admin,
A user can view,book and edit his tickets for a show
An admin has privileges to add/edit/remove the Show details
This project uses text files which will be created by the code itself .
This runs fine on the old turbo c++ (blue screen) ,so should be able to run on any compiler.
Now days, Detection of human head play an very important role in pedestrian counting. Machine learning is one platform, where human being can train a machine to act without being explicitly programmed and gives more accurate result, even when there is no enough data. Convolution neural network is one which works well for multimedia communication such as Text, Audio and Video. In this paper convnets play an important role in human head detection. In this paper it’s going to explain the less number of layers with more accuracy in the results with less time consuming.
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...gerogepatton
A support vector machine (SVM) learns the decision surface from two different classes of the input points, there are misclassifications in some of the input points in several applications. In this paper a bi-objective quadratic programming model is utilized and different feature quality measures are optimized simultaneously using the weighting method for solving our bi-objective quadratic programming problem. An important contribution will be added for the proposed bi-objective quadratic programming model by getting different efficient support vectors due to changing the weighting values. The numerical examples, give evidence of the effectiveness of the weighting parameters on reducing the misclassification between two classes of the input points. An interactive procedure will be added to identify the best compromise solution from the generated efficient solutions.
A FLOATING POINT DIVISION UNIT BASED ON TAYLOR-SERIES EXPANSION ALGORITHM AND...csandit
Floating point division, even though being an infrequent operation in the traditional sense, is
indis-pensable when it comes to a range of non-traditional applications such as K-Means
Clustering and QR Decomposition just to name a few. In such applications, hardware support
for floating point division would boost the performance of the entire system. In this paper, we
present a novel architecture for a floating point division unit based on the Taylor-series
expansion algorithm. We show that the Iterative Logarithmic Multiplier is very well suited to be
used as a part of this architecture. We propose an implementation of the powering unit that can
calculate an odd power and an even power of a number simultaneously, meanwhile having little
hardware overhead when compared to the Iterative Logarithmic Multiplier.
BARRACUDA, AN OPEN SOURCE FRAMEWORK FOR PARALLELIZING DIVIDE AND CONQUER ALGO...IJCI JOURNAL
This paper presents a newly-created Barracuda open-source framework which aims to parallelize Java divide and conquer applications. This framework exploits implicit for-loop parallelism in dividing and merging operations. So, this makes it a mixture of parallel for-loop and task parallelism. It targets sharedmemory multiprocessors and hybrid distributed shared-memory architectures. We highlight the effectiveness of the framework and focus on the performance gain and programming effort by using this framework. Barracuda aims at large public actors as well as various application domains. In terms of performance achievement, it is very close to Fork/Join framework while allowing end-users to only focus on refactoring code and experts to have the opportunity to improve it.
Duplicate Code Detection using Control StatementsEditor IJCATR
Code clone detection is an important area of research as reusability is a key factor in software evolution. Duplicate code
degrades the design and structure of software and software qualities like readability, changeability, maintainability. Code clone
increases the maintenance cost as incorrect changes in copied code may lead to more errors. In this paper we address structural code
similarity detection and propose new methods to detect structural clones using structure of control statements. By structure we mean
order of control statements used in the source code. We have considered two orders of control structures: (i) Sequence of control
statements as it appears (ii) Execution flow of control statements.
Duplicate Code Detection using Control StatementsEditor IJCATR
Code clone detection is an important area of research as reusability is a key factor in software evolution. Duplicate code
degrades the design and structure of software and software qualities like readability, changeability, maintainability. Code clone
increases the maintenance cost as incorrect changes in copied code may lead to more errors. In this paper we address structural code
similarity detection and propose new methods to detect structural clones using structure of control statements. By structure we mean
order of control statements used in the source code. We have considered two orders of control structures: (i) Sequence of control
statements as it appears (ii) Execution flow of control statements.
Duplicate Code Detection using Control StatementsEditor IJCATR
Code clone detection is an important area of research as reusability is a key factor in software evolution. Duplicate code
degrades the design and structure of software and software qualities like readability, changeability, maintainability. Code clone
increases the maintenance cost as incorrect changes in copied code may lead to more errors. In this paper we address structural code
similarity detection and propose new methods to detect structural clones using structure of control statements. By structure we mean
order of control statements used in the source code. We have considered two orders of control structures: (i) Sequence of control
statements as it appears (ii) Execution flow of control statements.
A High Speed Transposed Form FIR Filter Using Floating Point Dadda MultiplierIJRES Journal
There is a huge demand in high speed area efficient parallel FIR filter using floating point dadda algorithm, due to increase performance of processing units. Area and spped are usually confictiong constraints so that improving speed results mostly in large areas. In our research we will try to determine the best solution to this problem by comparing the results of different multipliers. Different sized of two algorithm for high speed hardware multipliers were studied and implemented ie.dadda and booth multipliers. The working of these two multipliers were studied and implementing each of them separately in VHDL. The results of this research will help us to choose the better option between multipliers for floating point multiplier for fabricating different system.
CIS 1403 lab 3 functions and methods in JavaHamad Odhabi
This lab discusses and provides examples of both built-in and user-defined functions. In Java function are referred to as methods. Therefore, in the rest of this lab, the term methods will be used to refer to functions. The lab will cover the type of methods, naming of functions, the scope of variables and recursion.
1. University Of Manchester
School of Physics and Astronomy
Object-Oriented Programming in C++ Project
Report
ListMyPolygons
Author:
Riccardo WIlliam Monfardini
Student ID: 7484334
October 29, 2013
2. Abstract
ListMyPolygons is a programme designed to input and modify con-
vex polygon details using the Translation, Rescale and Rotation trans-
formations. Details of the polygons are derived from their vertices; the
coordinates of them are saved using an independent matrix class; this
is designed to perform matrix arithmetic needed for transformations.
Polygons and input vertices use the STL vector container which can
grow and does not limit the number of these. Polymorphism is used
to access polygons saved as different derived classes depending on the
number of their vertices. The User interface has been designed to give
options on how to input and modify the polygons.
1 Introduction
The program ListMyPolygons is written using object-oriented programming
in C++. The aim of the program is to allow a user to input the details
of several different polygons, to make transformations such as translation,
rescaling and rotation, and display the information on the console screen. A
polygon is defined by its vertices and thus it is required to store these in a
sensible manner; it has been chosen to use matrices, specifically a 2 × 1 ma-
trix, to store the x and y coordinates of the vertices. The design of the matrix
class had to take into consideration the requirements needed to complete the
transformations, with particular attention dedicated to the rotation trans-
formation; this was obtained applying the rotation operator at each vertex,
defined by a square matrix.
2 Code design and Implementation
The code design can be divided into 3 main entities:
• matrix class,
• polygon class, and
• user interface,
and therefore a detailed explanation of each is given.
2.1 Matrix Class
As mentioned a matrix class was designed; displayed in Figure 1 is a di-
agram which points out the matrix class features of interest used in the
ListMyPolygons program. The variables of a matrix are the number of rows
1
3. and columns, and the value of each element of the matrix. For the purposes
of ListMyPolygons two constructors were used:
• a 2 × 1 matrix constructor used for vertices, and the translation vector
which will be discussed later in section 2.2; this will accept and store
the 2 coordinates, x and y.
• a 2×2 matrix constructor used for the rotation operator square matrix.
Constructing the new matrix class required the overloading of the addi-
tion and multiplication operators because, as shown in Figure 1, these two
operators are connected to the transformation functions. The overloaded
operators have checks to insure that the size of the matrices are compatible
for the upcoming operation. Matrix addition can occur only when they are
the same size while matrix multiplication can occur only when the number
of columns of the left matrix are equal to the number of rows of the right
matrix. The addition operator added element to element; multiplication by a
constant multiplied each element by a factor; matrix multiplication returned
the product matrix according to the standard rules. Even if this program
is designed only for 2D polygons the matrix class, which was constructed
independently, can be extended to greater dimensions by updating the con-
structors; the overloaded functions are programmed to work correctly with
matrices of any dimensions.
Figure 1: Diagram illustrating matrix class components. Notice how the matrix addi-
tion, matrix multiplication and multiply by a constant functions are linked to the external
transformation functions.
2
4. 2.2 Polygon Class
The second main entity in the design of ListMyPolygons is the polygon class
itself. Figure 2 shows a schematic representation of the design of this entity.
An abstract class named shape was designed to be the parent of all possible
polygons. From this, 5 derived classes were defined: trigon, tetragon, pen-
tagon, hexagon, and a generic polygon . The use of an abstract class allows
the exploitation of the polymorphism feature of object oriented C++: the
abstract class can be used as pointer to access the functions of the derived
classes which are defined with the same name.
Because the derived polygon classes all had similar functions, only a
schematic representation of the tetragon class is shown in Figure 2. The
polygons can be constructed in 2 ways: with the individual matrix of each
vertex or the std::vector container formed by vertex matrices. The con-
structor determined the values of the other parameters: the arrays side and
diagonal were determined by the difference between vertices. They used two
functions:
• diagonals, which return the number of possible diagonals (NofD) given
the number of vertices (NofV), and
• magnitude, which returned the magnitude of a vector, a row matrix.
An exception is made for the polygon class. Used as a class for polygons with
more than 6 vertices, it can only be constructed by a vector of matrices; this
allows the program to define NofV by its size. Thanks to this information
the type of polygon is found, such as Isosceles Triangle, Rectangle, Irregular
Hexagon, Irregular Polygon etc. Regular polygons are determined as well, for
example Equilateral Triangle, Regular Pentagon etc.; however these polygons
were found to be unreliable, as is discussed in section 3. The function info
is designed to output the details of the polygon onto the console screen for
the user to review.
The complex feature of these classes is the transformation functions,
Translation, Rescale and Rotation. As illustrated by Figure 2 Rescale and
Rotation are dependent on Translation and the function centroid. Transla-
tion uses a 2 × 1 matrix vector which is added to each vertex thanks to the
matrix addition discussed previously. Rescale and Rotation, however, have to
be performed with respect to a point or axis. Thus, before performing these
transformations, the polygon centre, found through the centroid function, is
translated to the origin. At this point the vertices are rescaled or rotated by
multiplying by a factor or the rotation matrix operator respectively. Finally
the polygons are translated back to their original position.
3
5. Abstract Base
Class Shape
Class Trigon;
NofV, vertices, side
NofD, diagonal, type
Class Tetragon;
NofV, vertices, side
NofD, diagonal, type
Class Pentagon;
NofV, vertices, side
NofD, diagonal, type
Class Polygon;
NofV, vertices, side
NofD, diagonal, type
trigon( A, B, C, D)
trigon( vector<matrix> vertices )
diagonals()
centroid()
Translation
Rotation
Rescale
vector
Matrix Addition
Multiply by
a constant
Matrix Multiplication
factor
rotation
matrix operator
Constructors
Translated to the origin
rescaling and roattion
with respect to the centre
Tetragon used as an example
other classes have a similar
configuraition
info()
magintude()
Class Hexagon;
NofV, vertices, side
NofD, diagonal, type
Derivate classes
Figure 2: Diagram illustrating the Shape class and its derived classes Trigon, Tetragon,
Pentagon and Hexagon, and the generic Polygon. Tetragon is used as an example since
all derived classes have a similar configuration. The dashed line figures indicate elements
which come from outside the class. Notice how Rescale and Rotation transformations are
dependent on Translation and the centroid functions.
4
6. 2.3 User Interface
The last entity of the program is the user interface (UI). The first part of
the UI is to ask the user to input the details of the polygon to be created;
this is illustrated by Figure 3. After a short introduction message, the user
chooses between two input methods. In method 1 he inputs the coordinates
of the vertices which are stored in a std::vector of matrices inputvertices.
The user can choose the NofV a priori or decide after each input if he wants
another vertex. Method 2 gives a short list of polygons to choose from:
one generic polygon and the 4 specific polygons, which copy method 1 but
with a undefined and predetermined NofV respectively; more interesting are
the options Rectangle, Isosceles Triangle and Square, which, based on User
input of base and height or side length, creates the std::vector of matrices
inputvertices placing one at the origin. The program creates the polygon of
class based on the size of inputvertices.
The second part of the UI, illustrated in Figure 4, allows the User to
review and modify the polygons created. The created polygon is stored
in a std::vector of shape pointers called polygons. Using the info function
previously mentioned, information about the polygon is printed to the screen.
The user is then asked if he wants to modify that newly created polygon.
A positive answer allows transformation of the polygon and printing of the
details, and the User is asked if he wants to modify it again. The destroy
option will delete the polygon. A negative answer allows the user to input a
new polygon with the same method or choose a different one. At the end of
the program all information about the polygons inserted are printed to the
screen for a final review, modification or destruction.
5
7. Introduction to the program
SaveMyPolygons
Choose
input
method
input each vertex
Do you know
how many
vertices?
Input vertex coordinates
Another
vertex?
Isoceles
Triangle
choose
from a list
SquareRectangle
Pentagon
Hexagon
yes
vector<matrix>
inputvertices
Determine polygon
depending on size
inputvertices
input number
of vertices
Input vertex coordinates
Create Polygon
Input base
and height
input
side
Place one vertex at origin and
determine the position
of other vertices
no
1 2
no
yes
Trigon
Tetragon
Polygon
Figure 3: Flowchart illustrating the first part of the User Interface, input of the polygon
details.
6
8. Figure 4: Flowchart illustrating the first part of the User Interface, reviewing and modi-
fication of the polygon details.
7
9. 3 Results & Limitations
The ListMyPolygons results and limitations are better explained with an
example of a User utilising the program.
After a greeting message the User is prompted to choose the input method,
shown in figure 5. Here it is requested to input the vertices, whenever asked,
Figure 5: Choosing the input method with a warning message.
in the same way the User would draw them. In fact the program allows the
input of concave polygons. Thus he is advised to use the program only for
convex polygons. The User chooses the input method 1 which asks him if
he knows how many vertices he would like to input. The program will loop
NofV times a request of vertex coordinates input if defined; otherwise after 3
requests it will ask the User if he wants another vertex. In this case, shown
in Figure 6 the user has chosen 3 NofV. The User has entered the vertices of
Figure 6: Input of the vertices and details of the polygon created.
an Isosceles Triangle at (0, 0), (5, 0), and (2.5, 2.5). Notice how the program
printed an error message when an invalid type is given. The program has
been designed to check the inputs to determine if they are the right boolean,
8
10. integer or double type, using the std::cin goodbit flag. Then the polygon is
created and its details are printed to the console screen. The same figure can
be created using input method 2, as is shown in Figure 7. After the creation
Figure 7: Creating an Isosceles Triangle as in Figure 6 using method 2.
of each polygon the User is prompted to choose a modify option. Figure
8 shows the User rescaling the Isosceles Triangle by a factor of 2 and then
translating it by (−5, 0). Notice how the User chooses a bad option with
the input of 4; this was refused by the program. All choosing options are
checked, apart for the integer type check, to determine if the specific option
exists. During the rescaling transformation the centre has not changed, as
discussed in section 2.2, since the function embeds a translation to the origin
and back.
The User created a rectangle which he decided to rotate by −π/2, as
shown in Figure 9. Here the user had to input the rotation operator matrix,
which in this case is ( 0 1
−1 0 ). As in the rescaling transformation the centre has
not changed because of the embedded translation to the origin and back.
9
11. Figure 8: User rescales the Isosceles Triangle and translates it.
Figure 9: The User creates and rotates a rectangle
10
12. In Figure 10 the User enters a pentagon but inputs the wrong vertices.
Checking the polygon details it is seen that it describes a concave polygon,
and 2 vertices are one on top of each other. At this point, the option destroy
Figure 10: User notices that input vertices are incorrect and decides to destroy the last
polygon.
allows him to delete the polygon. This option uses the vector::pop back()
function to eliminate the last polygon which was saved, since polygons are
saved using vector::push back(). This is possible because the polygons are
stored in a vector shape pointer (std::vector<shape*>) called “polygons”;
an extra advantage of using vectors is that their size can change dynamically
and thus the User is not restricted by a predetermined maximum amount of
polygons.
Finally, after the insertion of all the polygons wanted by the user, the
complete list is printed to the screen as is shown in figure 11. Here each
polygon is numbered; in case the user wishes to modify any of the polygons,
he can use the number to select it. The end of the program is reached when
a negative answer is given to the last modify question.
Thus summarising, the code takes advantage of advanced Object Oriented
programming in C++ features in several ways:
• Polymorphism, where an abstract class shape is used to access all
derived polygon class functions.
• Templates, where a valCheck function is used to check that the input
value is of the right type; this is done by checking the state of the
std::cin goodbit flag.
• Separation of Entities, where the matrix and polygon class are sep-
arated and each with its own header file.
11
14. 4 Conclusion & Discussion
The ListMyPolygons program was written to allow a User to insert several
polygons, modify them using the Translation, Rescale and Rotation trans-
formations. A polygon is essentially defined by the position of its vertices.
Thus other variables like side lengths, diagonal lengths, type of polygon were
determined from the vertices. The vertices were stored using a specifically de-
signed matrix class. This allowed matrix addition and multiplication, which
was particularly important with the matrix rotation operator in the Rota-
tion transformation. Both the vertices and the polygons were stored using
the vector STL container; this had the advantage of being able to grow, thus
not restricting the number of polygons stored or the number of vertices a
polygon could have.
The program could be improved by implementing 3D polygons. This
could be done by a small modification of the matrix class to allow 3 × 1 and
3 × 3 matrices. The 3D polygon classes could inherit from the 2D classes
already established. A correction of the truncation errors could improve the
reliability of regular polygons such as Equilateral Triangle. The program
could determine if a figure is concave to exclude them or use separate classes
to save them in.
13