0% found this document useful (0 votes)
25 views53 pages

C Programming in Linux 1st Edition by David Haskins 9788776814724 PDF Download

The document promotes the availability of various ebooks and textbooks on programming, particularly focusing on 'C Programming in Linux' by David Haskins. It provides links to download these resources and highlights the importance of learning the C language for software professionals. Additionally, it outlines the contents of the book, including chapters on data, functions, and graphics programming.

Uploaded by

lulovigudia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views53 pages

C Programming in Linux 1st Edition by David Haskins 9788776814724 PDF Download

The document promotes the availability of various ebooks and textbooks on programming, particularly focusing on 'C Programming in Linux' by David Haskins. It provides links to download these resources and highlights the importance of learning the C language for software professionals. Additionally, it outlines the contents of the book, including chapters on data, functions, and graphics programming.

Uploaded by

lulovigudia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Download the full version and explore a variety of ebooks

or text books at https://ebookball.com

C Programming in Linux 1st Edition by David


Haskins 9788776814724

_____ Follow the link below to get your download now _____

https://ebookball.com/product/c-programming-in-linux-1st-
edition-by-david-haskins-9788776814724-15294/

Access ebookball.com now to download high-quality


ebooks or textbooks
Here are some recommended products for you. Click the link to
download, or explore more at ebookball.com

Programming in Objective C 1st Edition by Stephen Kochan


067248420X 9780672484209

https://ebookball.com/product/programming-in-objective-c-1st-edition-
by-stephen-kochan-067248420x-9780672484209-15258/

Programming in C 4th edition by Stephen Kochan


9780132781190 0132781190

https://ebookball.com/product/programming-in-c-4th-edition-by-stephen-
kochan-9780132781190-0132781190-15230/

Memory as a Programming Concept in C and C 1st Edition by


Frantisek Franek isbn 0521520436 9780521520430

https://ebookball.com/product/memory-as-a-programming-concept-in-c-
and-c-1st-edition-by-frantisek-franek-
isbn-0521520436-9780521520430-12552/

Memory as a Programming Concept in C and C 1st Edition by


Frantisek Franek ISBN 051183862X 9780511838620

https://ebookball.com/product/memory-as-a-programming-concept-in-c-
and-c-1st-edition-by-frantisek-franek-
isbn-051183862x-9780511838620-14982/
Functional Programming in C 1st Edition by Enrico Buonanno
ISBN 9781638354048 1638354049

https://ebookball.com/product/functional-programming-in-c-1st-edition-
by-enrico-buonanno-isbn-9781638354048-1638354049-15788/

Object oriented programming in C 1st Edition by Nabajyoti


Barkakati 0672228009 9780672228001

https://ebookball.com/product/object-oriented-programming-in-c-1st-
edition-by-nabajyoti-barkakati-0672228009-9780672228001-15280/

Linux Assembly Language Programming 1st Edition by Bob


Neveln ISBN 0130879401 9780130879400

https://ebookball.com/product/linux-assembly-language-programming-1st-
edition-by-bob-neveln-isbn-0130879401-9780130879400-12096/

Object Oriented Programming in C 4th Edition by Robert


Lafore 0672323087 9780672323089

https://ebookball.com/product/object-oriented-programming-in-c-4th-
edition-by-robert-lafore-0672323087-9780672323089-16228/

Object Oriented Programming in C 4th Edition by Robert


Lafore ISBN 9780132714297 0132714299

https://ebookball.com/product/object-oriented-programming-in-c-4th-
edition-by-robert-lafore-isbn-9780132714297-0132714299-15546/
FREE ST U DY BOOKS

C PROGRAMMING
IN LINUX
DAVID HASKINS

FREE STUDY BOOKS


WWW.BOOKBOON.COM 1
David Haskins

C Programming in Linux

Download free books at BookBooN.com

2
C Programming in Linux
© 2009 David Haskins & Ventus Publishing ApS
ISBN 978-87-7681-472-4

Download free books at BookBooN.com

3
C Programming in Linux Contents

Contents
About the author, David Haskins 7

Introduction 8

Setting up your System 11

1. Chapter One: Hello World 13


1.1 Hello Program 1 13
1.2 Hello Program 2 14
1.3 Hello Program 3 17
1.4 Hello Program 4 19
1.5 Hello World conclusion 22

2. Data and Memory 23


2.1 Simple data types? 23
2.2 What is a string? 27
2.3 What can a string “mean” 28
2.4 Parsing a string 31
2.5 Data and Memory – conclusion 34
Please click the advert

Download free books at BookBooN.com

4
C Programming in Linux Contents

3. Functions, pointers and structures 35


3.1 Functions 35
3.2 Library Functions 38
3.3 A short library function reference 39
3.4 Data Structures 41
3.5 Functions, pointers and structures – conclusion 44

4. Logic, loops and flow control 46


4.1 Syntax of C Flow of control 46
4.2 Controlling what happens and in which order 47
4.3 Logic, loops and flow conclusion 57

5. Database handling with MySQL 58


5.1 On not reinventing the wheel 58
5.2 MySQL C API 58

6. Graphics with GD library 63


6.1 Generating binary content 63
6.2 Using TrueType Fonts 66
6.3 GD function reference 68
Please click the advert

We have ambitions. Also for you.


SimCorp is a global leader in financial software. At SimCorp, you will be part of a large network of competent
and skilled colleagues who all aspire to reach common goals with dedication and team spirit. We invest in our
employees to ensure that you can meet your ambitions on a personal as well as on a professional level. SimCorp
employs the best qualified people within economics, finance and IT, and the majority of our colleagues have a
university or business degree within these fields.

Ambitious? Look for opportunities at www.simcorp.com/careers

www.simcorp.com

Download free books at BookBooN.com

5
C Programming in Linux Contents

7. Apache C modules 73
7.1 Safer C web applications 73
7.2 Adding some functionality 76
7.3 Apache Modules Conclusion 77

8. The Ghost project 78


8.1 A PHP web site generator project 78

Conclusion 84

what‘s missing in this equation?


Please click the advert

You could be one of our future talents

MAERSK INTERNATIONAL TECHNOLOGY & SCIENCE PROGRAMME


Are you about to graduate as an engineer or geoscientist? Or have you already graduated?
If so, there may be an exciting future for you with A.P. Moller - Maersk.

www.maersk.com/mitas

Download free books at BookBooN.com

6
C Programming in Linux About the author, David Haskins

About the author, David Haskins

I was born in 1950 in Chelsea, London, but grew up in New Zealand returning to England in 1966. I
have worked in the computer industry since 1975 after a couple of years as a professional drummer.

My first experience was five years as a mainframe hardware engineer for Sperry Univac (now Unisys)
followed by 14 years as an analyst programmer with British Telecom in London.

While engaged in a complex task of converting large quantities of geographical data (map coordinate
references) I discovered the joys of C – its speed and efficiency. That was in 1985 and I have been a
fan of C ever since.

Since 1994 I have been a senior lecturer at the Faculty of Computing, Information Systems and
Mathematics at Kingston University, London. This is a mostly technical university that evolved from
a former polytechnic college with a long tradition of aeronautical engineering.

I am engaged mainly in teaching many computer languages and internet systems design to a large and
multicultural student body.

Most of my academic research and commercial consultancy has been involved with spatial systems
design and the large data volumes and necessary processing efficiency concerns has led me to
concentrate on C and C++. My teaching web site is at www.ubiubi.org which shows some of this
material.

A keen Open Systems enthusiast, I have exclusively centred all my teaching on the Linux platform
since 2002 and Kingston University is well advanced in delivering dual boot facilities for all its
student labs.

I am a keen swimmer and in 2009 completed the annual Lorne Pier-to-Pub race in Victoria, Australia
which is the largest open-sea swimming race in the world where 4,500 people of all ages swim each
January as the shark-spotting planes fly overhead.

When not teaching I am a keen vegetable gardener and amateur musician, playing in jazz groups and in
Scottish bagpipe bands. I play the drums, the great highland bagpipe, the clarinet, the guitar and the piano.

Download free books at BookBooN.com

7
C Programming in Linux Introduction

Introduction

Why learn the C language?

Because the C language is like Latin - it is finite and has not changed for years. C is tight and spare,
and in the current economic climate we will need a host of young people who know C to keep existing
critical systems running.

C is built right into the core of Linux and Unix. The design idea behind Unix was to write an
operating system in C so all you needed to port it to a new architecture was a C compiler. Linux is
essentially the success story of a series of earlier attempts to make a PC version of Unix.

A knowledge of C is now and has been for years a pre-requisite for serious software professionals and
with the recent popularity and maturity of Open Systems this is even more true. The terseness and
perceived difficulty of C saw it being ousted from university teaching during the late 1990s in favour
of Java but there is a growing feeling amongst some teaching communities that Java really is not such
a good place to start beginners.

Students paradoxically arrive at colleges knowing less about computing than they did ten years ago as
programming is seen as too difficult for schools to teach. Meanwhile the body of knowledge expected
of a competent IT professional inexorably doubles every few years.

Java is commonly taught as a first language but can cause student confusion as it is in constant flux, is
very abstract and powerful, and has become too big with too many different ways to do the same
thing. It also is a bit “safe” and insulates students from scary experiences, like driving with air-bags
and listening to headphones so you take less care. The core activity of writing procedural code within
methods seems impenetrable to those who start from classes and objects.

So where do we start? A sensible place is “at the beginning” and C is as close as most of us will ever
need to go unless we are becoming hardware designers. Even for these students to start at C and go
further down into the machine is a good idea.

C is like having a very sharp knife which can be dangerous, but if you were learning to be a chef you
would need one and probably cut yourself discovering what it can do. Similarly C expects you to
know what you are doing, and if you don't it will not warn before it crashes.

A knowledge of C will give you deep knowledge of what is going on beneath the surface of higher-
level languages like Java. The syntax of C pretty-well guarantees you will easily understand other
languages that came afterwards like C++, Java, Javascript, and C#.

C gives you access to the heart of the machine and all its resources at a fine-grained bit-level.

Download free books at BookBooN.com

8
C Programming in Linux Introduction

C has been described as like “driving a Porsche with no brakes” - and because it is fast as well this can
be exhilarating. C is is often the only option when speed and efficiency is crucial.

C has been called “dangerous” in that it allows low-level access to the machine but this scariness
is exactly what you need to understand as it gives you respect for the higher-level languages you
will use.

Many embedded miniaturised systems are all still written in C and the machine-to-machine world of
the invisible internet for monitoring and process control often uses C.

Hopefully this list of reasons will start you thinking that it might be a good reason to have a go at
this course.

References

The C Programming Language – Second Edition - Kernighan and Richie


ISBN 0-13-11-362-8

The GNU C Library Free Software Foundation C Manual


http://www.gnu.org/software/libc/manual/

MySQL C library
http://dev.mysql.com/doc/refman/5.1/en/index.html

The GD C library for graphics


http://www.libgd.org/Documentation

APXS - the APache eXtenSion tool


http://httpd.apache.org/docs/2.0/programs/apxs.html

Apache
http://httpd.apache.org/docs/2.2/developer/

“The Apache Modules Book” Nick Kew, Prentice Hall


ISBN 0-13-240967-4

A Source Code Zip File Bundle is supplied with this course which contains all the material described
and a Makefile.

Download free books at BookBooN.com

9
C Programming in Linux Introduction

The teaching approach

I began university teaching later in life after a career programming in the telecommunications industry.

My concern has been to convey the sheer fun and creativity involved in getting computers to do what
you want them to do and always try to give useful, practical, working examples of the kinds of things
students commonly tell me they want to do.

Learning a language can be a dry, boring affair unless results are immediate and visible so I tend to use
the internet as the input-output channel right from the start.

I prefer teaching an approach to programming which is deliberately “simple” using old-fashioned


command-line tools and editors and stable, relatively unchanging components that are already built-in
to Unix and Linux distributions such as Suse, Ubuntu and Red Hat.

This is in response to the growing complexity of modern Integrated Development Environments


(IDEs) such as Developer Studio, Netbeans and Eclipse which give students an illusion that they know
what they are doing but generate obfuscation.

My aim is to get students confident and up to speed quickly without all the nightmare associated with
configuring complex tool chains. It is also essentially a license-free approach and runs on anything.

With this fundamental understanding about what is really going on you can progress on to use and
actually understand whatever tools you need in your career.

In order to give a sense of doing something real and useful and up to date, the focus is on developing
visible and effectively professional-quality web-server and client projects to put on-line, using:

Apache Web server and development libraries.


C language CGI programs (C programming using the “make” utility).
C language Apache modules.
MySQL server with C client library interfaces.
GD graphics library with C interfaces.
Incidental use of CSS, (X)HTML, XML, JavaScript, Ajax.

This course has been designed for and lab-tested by first and second year Computer Science Students
at Kingston University, London UK.

Download free books at BookBooN.com

10
C Programming in Linux Setting up your System

Setting up your System


This book presumes you are using the Linux operating system with either the KDE3.5, KDE4, or
Gnome desktop. Specific instructions are included for Ubuntu (and Kubuntu) and OpenSuse 11.

If you are using the KDE desktop you will have Konqueror or Dolphin as the File Manager and kate or
kedit for an editor

In Gnome you would probably use Nautilus and gedit

You need to be familiar with the idea of doing some things as “super user” so that you have access
permission to copy or edit certain files. This is normally done by prefacing the Linux command with
“sudo” and providing the password, as in this example:

“sudo cp hello3 /srv/www/cgi-bin/hello3”

which copies the file “hello3” to the area where the Apache server locates common gateway interface
or cgi programs.

In KDE “kdesu konqueror” would open a file manager as super user.

In Gnome “gnomesu nautilus” would open a file manager as super user.

You will need to have installed the following packages:

package Ubuntu Open Suse

C development libraries build-essential Base Development (pattern)

Apache web server apache2 Web and LAMP Server (pattern)

Apache development libraries apache2-prefork-dev apache2-devel

MySQL server, client and mysql-server libmysqlclient15- libmysqlclient-devel


development libraries dev

GD and development libraries libgd2-xpm gd


gd-devel

Throughout the text you will see references to the folder cgi-bin. The location of this will vary
between Linux distributions. By default this folder used for web programs is:

OpenSuse: /srv/www/cgi-bin
Ubuntu: /usr/lib/cgi-bin

Download free books at BookBooN.com

11
C Programming in Linux Setting up your System

To place programs there you need superuser rights, so it may be better to create a folder inside your
own home/*****/public_html/cgi-bin directory and change the ScriptAlias and associated Directory
references inside the Apache configuration files (OpenSuse) /etc/apache2/default-server.conf or
(Ubuntu) /etc/apache2/default-server.conf.

it’s an interesting world

Where it’s
Please click the advert

Student and Graduate opportunities in IT, Internet & Engineering


Cheltenham | £competitive + benefits
Part of the UK’s intelligence services, our role is to counter threats that compromise national and global
security. We work in one of the most diverse, creative and technically challenging IT cultures. Throw in
continuous professional development, and you get truly interesting work, in a genuinely inspirational business.

To find out more visit www.careersinbritishintelligence.co.uk


Applicants must be British citizens. GCHQ values diversity and welcomes applicants from all sections of the community.
We want our workforce to reflect the diversity of our work.

Download free books at BookBooN.com

12
C Programming in Linux Chapter One: Hello World

1. Chapter One: Hello World

1.1 Hello Program 1

Using the File Manager (in KDE, Konqueror or in Gnome, Nautilus) create a new directory
somewhere in your home directory called something appropriate for all the examples in this book,
perhaps “Programming_In_Linux” without any spaces in the name.

Open an editor (in KDE, kate, or in Gnome, gedit) and type in (or copy from the supplied source code
zip bundle) the following:

/*****************************************************************
C Programming in Linux (c) David Haskins 2008
chapter1_1.c
*****************************************************************/
#include <stdio.h>

int main(int argc, char *argv[])


{
printf("Hello, you are learning C!!\n");
return 0;
}

Save the text as chapter1_1.c in the new folder you created in your home directory.

Open a terminal window and type: gcc -o hello chapter1_1.c


to compile the program into a form that can be executed.

Now type “ls -l” to list the details of all the files in this directory. You should see that chapter1_2.c is
there and a file called “hello” which is the compiled C program you have just written.

Now type: ./hello


to execute, or run the program and it should return the text:

"Hello you are learning C!!".

If this worked, congratulations, you are now a programmer!

Download free books at BookBooN.com

13
C Programming in Linux Chapter One: Hello World

Anatomy of the program:

The part inside /*** ***/ is a comment and is not compiled but just for information and
reference.

The “#include...” part tells the compiler which system libraries are needed and which header files
are being referenced by this program. In our case “printf” is used and this is defined in the
stdio.h header.

The “int main(int argc, char *argv[])” part is the start of the actual program. This is an entry-
point and most C programs have a main function.

The “int argc” is an argument to the function “main” which is an integer count of the number of
character string arguments passed in “char *argv[]” (a list of pointers to character strings) that
might be passed at the command line when we run it.

A pointer to some thing is a name given to a memory address for this kind of data type. We can
have a pointer to an integer: int *iptr, or a floating point number: float *fPtr. Any list of things is
described by [], and if we know exactly how big this list is we might declare it as [200]. In this
case we know that the second argument is a list of pointers to character strings.

Everything else in the curly brackets is the main function and in this case the entire program
expressed as lines.

Each line or statement end with a semi-colon “;”.

We have function calls like “printf(...)” which is a call to the standard input / output library
defined in the header file stdio.h.

At the end of the program “return 0” ends the program by returning a zero to the system.

Return values are often used to indicate the success or status should the program not run
correctly.

1.2 Hello Program 2

Taking this example a stage further, examine the start of the program at the declaration of the entry
point function: int main(int argc, char *argv[])

In plain English this means:

Download free books at BookBooN.com

14
C Programming in Linux Chapter One: Hello World

The function called “main”, which returns an integer, takes two arguments, an integer called “argc”
which is a count of the number of command arguments then *argv[] which is a list or array of pointers
to strings which are the actual arguments typed in when you run the program from the command line.

Some Definitions:

function: a block of program code with a return data type, a name, some arguments of varying
data types separated by commas, enclosed in brackets, then the body of the function enclosed in
curly brackets, each statement ending with a semi-colon.
integer symbol int : a counting number like 0,1,2,3,4,5.
list, array symbol []: a sequence of things of the same kind in a numbered order.
pointer symbol * : a memory address locating the start of piece of data of a certain type.
string or char * : a pointer to a sequence of characters like 'c' ,'a', 't' making up “cat”. A
character string ends with s special character NULL or '\0' ascii value 0 or hex 00

DIVERSE - INNOVATIVE - INTERNATIONAL

Are you considering a European business degree?


Please click the advert

Copenhagen Business School is one of the largest business schools in


Northern Europe with more than 15,000 students from Europe, North
America, Australia and Asia.

Are you curious to know how a modern European business school


competes with a diverse, innovative and international study
environment?

Please visit Copenhagen Business School at www.cbs.dk

Diversity creating knowledge

Download free books at BookBooN.com

15
Other documents randomly have
different content
Fig. 71.

Fig. 71. will show the law with sufficient clearness; it represents the
perspective construction of a fillet whose profile is a semicircle, such
as f h in Fig. 60., seen above the eye. Only half the pillar with half
the fillet is drawn, to avoid confusion.
q93is the center of the shaft.
p q the thickness of the fillet, sight-magnitude at the shaft’s center.

Round p a horizontal semicircle is drawn on the diameter of the shaft


a b.
Round q another horizontal semicircle is drawn on diameter c d.
These two semicircles are the upper and lower edges of the fillet.
Then diagonals and diameters are drawn as in Fig. 68., and, at their
extremities, semicircles in perspective, as in Fig. 69.
The letters a, b, c, d, and e, indicate the upper and exterior angles
of the rectangles in which these semicircles are to be drawn; but the
inner vertical line is not dotted in the rectangle at c, as it would have
confused itself with other lines.
Then the visible contour of the fillet is the line which incloses and
touches33 all the semicircles. It disappears behind the shaft at the
point h, but I have drawn it through to the opposite extremity of the
diameter at d.
Turned upside down the figure shows the construction of a basic
fillet.
The capital of a Greek Doric pillar should be drawn frequently for
exercise on this fourteenth problem, the curve of its echinus being
exquisitely subtle, while the general contour is simple.

32 This point coincides in the figure with the extremity of the horizontal diameter, but
only accidentally. Return to text

33 The engraving is a little inaccurate; the inclosing line should touch the dotted
semicircles at a and b. The student should draw it on a large scale.
Return to text
94
PROBLEM XVI.
It is often possible to shorten other perspective operations
considerably, by finding the vanishing-points of the inclined lines of
the object. Thus, in drawing the gabled roof in Fig. 43., if the gable
a y c be drawn in perspective, and the vanishing-point of a y
determined, it is not necessary to draw the two sides of the
rectangle, a′ d′ and d′ b′, in order to determine the point y′; but
merely to draw y y′ to the vanishing-point of a a′ and a′ y′ to the
vanishing-point of a y, meeting in y′, the point required.
Again, if there be a series of gables, or other figures produced by
parallel inclined lines, and retiring to the point v, as in Fig. 72.,34 it is
not necessary to draw each separately, but merely to determine their
breadths on the line a v, and draw the slopes of each to their
vanishing-points, as shown in Fig. 72. Or if the gables are equal in
height, and a line be drawn from y to v, the construction resolves
itself into a zigzag drawn alternately to p and q, between the lines
y v and a v.
The student must be very cautious, in finding the vanishing-points of
inclined lines, to notice their relations to the horizontals beneath
them, else he may easily mistake the horizontal to which they
belong.
Thus, let a b c d, Fig. 73., be a rectangular inclined plane, and let it
be required to find the vanishing-point of its diagonal b d.
Find v, the vanishing-point of a d and b c.
Draw a e to the opposite vanishing-point, so that d a e may
represent a right angle.
Let fall from b the vertical b e, cutting a e in e.
Join e d, and produce it to cut the sight-line in v′.

95

Fig. 72.
Then,
96 since the point e is vertically under the point b, the horizontal
line e d is vertically under the inclined line b d.

Fig. 73.

So that if we now let fall the vertical v′ p from v′, and produce b d to
cut v′ p in p, the point p will be the vanishing-point of b d, and of all
lines parallel to it.35

34 The diagram is inaccurately cut. y v should be a right line. Return to text

35 The student may perhaps understand this construction better by completing the
rectangle a d f e, drawing d f to the vanishing-point of a e, and e f to v. The whole
figure, b f, may then be conceived as representing half the gable roof of a house,
a f the rectangle of its base, and a c the rectangle of its sloping side.

In nearly all picturesque buildings, especially on the Continent, the slopes of gables
are much varied (frequently unequal on the two sides), and the vanishing-points of
their inclined lines become very important, if accuracy is required in the
intersections of tiling, sides of dormer windows, etc.
Obviously, also, irregular triangles and polygons in vertical planes may be more
easily constructed by finding the vanishing-points of their sides, than by the
construction given in the corollary to Problem IX.; and if such triangles or polygons
have others concentrically inscribed within them, as often in Byzantine mosaics, etc.,
the use of the vanishing-points will become essential. Return to text
97
PROBLEM XVIII.
Before examining the last three problems it is necessary that you
should understand accurately what is meant by the position of an
inclined plane.
Cut a piece of strong white pasteboard into any irregular shape, and
dip it in a sloped position into water. However you hold it, the edge
of the water, of course, will always draw a horizontal line across its
surface. The direction of this horizontal line is the direction of the
inclined plane. (In beds of rock geologists call it their “strike.”)

Fig. 74.

Next, draw a semicircle on the piece of pasteboard; draw its


diameter, a b, Fig. 74., and a vertical line from its center, c d; and
draw some other lines, c e, c f, etc., from the center to any points in
the circumference.
Now dip the piece of pasteboard again into water, and, holding it at
any inclination and in any direction you choose, bring the surface of
the water to the line a b. Then the line c d will be the most steeply
inclined of all the lines drawn to the circumference of the circle; g c
and h c will be less steep; and e c and f c less steep still. The nearer
the lines to c d, the steeper they will be; and the nearer to a b, the
more nearly horizontal.
When,
98 therefore, the line a b is horizontal (or marks the water
surface), its direction is the direction of the inclined plane, and the
inclination of the line d c is the inclination of the inclined plane. In
beds of rock geologists call the inclination of the line d c their “dip.”
To fix the position of an inclined plane, therefore, is to determine the
direction of any two lines in the plane, a b and c d, of which one
shall be horizontal and the other at right angles to it. Then any lines
drawn in the inclined plane, parallel to a b, will be horizontal; and
lines drawn parallel to c d will be as steep as c d, and are spoken of
in the text as the “steepest lines” in the plane.
But farther, whatever the direction of a plane may be, if it be
extended indefinitely, it will be terminated, to the eye of the
observer, by a boundary line, which, in a horizontal plane, is
horizontal (coinciding nearly with the visible horizon);—in a vertical
plane, is vertical;—and, in an inclined plane, is inclined.
This line is properly, in each case, called the “sight-line” of such
plane; but it is only properly called the “horizon” in the case of a
horizontal plane: and I have preferred using always the term “sight-
line,” not only because more comprehensive, but more accurate; for
though the curvature of the earth’s surface is so slight that
practically its visible limit always coincides with the sight-line of a
horizontal plane, it does not mathematically coincide with it, and the
two lines ought not to be considered as theoretically identical,
though they are so in practice.
It is evident that all vanishing-points of lines in any plane must be
found on its sight-line, and, therefore, that the sight-line of any
plane may be found by joining any two of such vanishing-points.
Hence the construction of Problem XVIII.
99
II.

DEMONSTRATIONS WHICH COULD NOT


CONVENIENTLY BE INCLUDED IN THE TEXT.

I.
THE SECOND COROLLARY, PROBLEM II.

In Fig. 8. omit the lines c d, c′ d′, and d s; and, as here in Fig. 75.,
from a draw a d parallel to a b, cutting b t in d; and from d draw d e
parallel to b c′.
Fig. 75.

Now as a d is parallel to a b—

a c ∶ a c ∷ b c′ ∶ d e;
but a c is equal to b c′—
∴ a c = d e.

Now
100 because the triangles a c v, b c′ v, are similar—

a c ∶ b c′ ∷ a v ∶ b v;
and because the triangles d e t, b c′ t are similar—
d e ∶ b c′ ∷ d t ∶ b t.

But a c is equal to d e—
∴ a v ∶ b v ∷ d t ∶ b t;
∴ the two triangles a b d, b t v, are similar, and their angles are
alternate;
∴ t v is parallel to a d.
But a d is parallel to a b—

∴ t v is parallel to a b.
101
II.
THE THIRD COROLLARY, PROBLEM III.

In Fig. 13., since a r is by construction parallel to a b in Fig. 12., and


t v is by construction in Problem III. also parallel to a b—

∴ a r is parallel to t v,
∴ a b r and t b v are alternate triangles,
∴ a r ∶ t v ∷ a b ∶ b v.

Again, by the construction of Fig. 13., a r′ is parallel to m v—

∴ a b r′ and m b v are alternate triangles,


∴ a r′ ∶ m v ∷ a b ∶ b v.

And it has just been shown that also

a r ∶ t v ∷ a b ∶ b v—
∴ a r′ ∶ m v ∷ a r ∶ t v.

But by construction, a r′ = a r—

∴ m v = t v.
102
III.
ANALYSIS OF PROBLEM XV.

We proceed to take up the general condition of the second problem,


before left unexamined, namely, that in which the vertical distances
b c′ and a c (Fig. 6. page 13), as well as the direct distances t d and
t d′ are unequal.
In Fig. 6., here repeated (Fig. 76.), produce c′ b downwards, and
make c′ e equal to c a.
Fig. 76.

Join a e.
Then, by the second Corollary of Problem II., a e is a horizontal line.

Draw t v parallel to a e, cutting the sight-line in v.

∴ v is the vanishing-point of a e.

Complete
103 the constructions of Problem II. and its second Corollary.
Then by Problem II. a b is the line a b drawn in perspective; and by
its Corollary a e is the line a e drawn in perspective.

From v erect perpendicular v p, and produce a b to cut it in p.


Join t p, and from e draw e f parallel to a e, and cutting a t in f.
Now in triangles e b t and a e t, as e b is parallel to e b and e f to
a e;—e b ∶ e f ∷ e b ∶ a e.
But t v is also parallel to a e and p v to e b.
Therefore also in the triangles a p v and a v t,

e b ∶ e f ∷ p v ∶ v t.

Therefore p v ∶ v t ∷ e b ∶ a e.
And, by construction, angle t p v = ∠ a e b.
Therefore the triangles t v p, a e b, are similar; and t p is parallel to
a b.

Now
104 the construction in this problem is entirely general for any
inclined line a b, and a horizontal line a e in the same vertical plane
with it.
So that if we find the vanishing-point of a e in v, and from v erect a
vertical v p, and from t draw t p parallel to a b, cutting v p in p, p
will be the vanishing-point of a b, and (by the same proof as that
given at page 17) of all lines parallel to it.
Fig. 77.

Next, to find the dividing-point of the inclined line.


I remove some unnecessary lines from the last figure and repeat it
here, Fig. 77., adding the measuring-line a m, that the student may
observe its position with respect to the other lines before I remove
any more of them.
Now if the line a b in this diagram represented the length of the line
a b in reality (as a b does in Figs. 10. and 11.), we should only have
to proceed to modify Corollary III. of Problem II. to this new
construction. We shall see presently that a b does not represent the
actual length of the inclined line a b in nature, nevertheless we shall
first proceed as if it did, and modify our result afterwards.
105Fig. 77. draw a d parallel to a b, cutting b t in d.
In
Therefore a d is the sight-magnitude of a b, as a r is of a b in
Fig. 11.

Fig. 78.

Remove again from the figure all lines except p v, v t, p t, a b, a d,


and the measuring-line.
Set off on the measuring-line a m equal to a d.
Draw p q parallel to a m, and through b draw m q, cutting p q in q.
Then, by the proof already given in page 20, p q = p t.
Therefore if p is the vanishing-point of an inclined line a b, and q p is
a horizontal line drawn through it, make p q equal to p t, and a m on
the measuring-line equal to the sight-magnitude of the line a b in the
diagram, and the line joining m q will cut a p in b.

We have now, therefore, to consider what relation the length of the


line a b in this diagram, Fig. 77., has to the length of the line a b in
reality.
Now the line a e in Fig. 77. represents the length of a e in reality.

But the angle a e b, Fig. 77., and the corresponding angle in all the
constructions of the earlier problems, is in reality a right angle,
though in the diagram necessarily represented as obtuse.
Therefore, if from e we draw e c, as in Fig. 79.,
at right angles to a e, make e c = e b, and join
a c, a c will be the real length of the line a b.
Now, therefore, if instead of a m in Fig. 78., we
take the real length of a b, that real length will
be to a m as a c to a b in Fig. 79.
Fig. 79.
And then, if the line drawn to the measuring-line
p q is still to cut a p in b, it is evident that the line p q must be
shortened in the same ratio that a m was shortened; and the true
dividing-point will be q′ in Fig. 80., fixed so that q′ p shall be to q p
as a m′ is to a m; a m′ representing the real length of a b.
106 a m′ is therefore to a m as a c is to a b in Fig. 79.
But
Therefore p q′ must be to p q as a c is to a b.
But p q equals p t (Fig. 78.); and p v is to v t (in Fig. 78.) as b e is to
a e (Fig. 79.).
Hence we have only to substitute p v for e c, and v t for a e, in
Fig. 79., and the resulting diagonal a c will be the required length of
p q′.
Fig. 80.

It will be seen that the construction given in the text (Fig. 46.) is the
simplest means of obtaining this magnitude, for v d in Fig. 46. (or
v m in Fig. 15.) = v t by construction in Problem IV. It should,
however, be observed, that the distance p q′ or p x, in Fig. 46., may
be laid on the sight-line of the inclined plane itself, if the measuring-
line be drawn parallel to that sight-line. And thus any form may be
drawn on an inclined plane as conveniently as on a horizontal one,
with the single exception of the radiation of the verticals, which have
a vanishing-point, as shown in Problem XX.

the end.
Transcriber’s Note
A handful of unequivocal typographical errors has been
corrected.
For increased clarity, a few diagrams have been shifted from
their original position in the text.
*** END OF THE PROJECT GUTENBERG EBOOK THE ELEMENTS OF
PERSPECTIVE ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.

1.C. The Project Gutenberg Literary Archive Foundation (“the


Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:
1.E.1. The following sentence, with active links to, or other
immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.
1.E.4. Do not unlink or detach or remove the full Project
Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using
the method you already use to calculate your applicable
taxes. The fee is owed to the owner of the Project
Gutenberg™ trademark, but he has agreed to donate
royalties under this paragraph to the Project Gutenberg
Literary Archive Foundation. Royalty payments must be paid
within 60 days following each date on which you prepare (or
are legally required to prepare) your periodic tax returns.
Royalty payments should be clearly marked as such and sent
to the Project Gutenberg Literary Archive Foundation at the
address specified in Section 4, “Information about donations
to the Project Gutenberg Literary Archive Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of
receipt that s/he does not agree to the terms of the full
Project Gutenberg™ License. You must require such a user
to return or destroy all copies of the works possessed in a
physical medium and discontinue all use of and all access to
other copies of Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full


refund of any money paid for a work or a replacement copy,
if a defect in the electronic work is discovered and reported
to you within 90 days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.
1.F.1. Project Gutenberg volunteers and employees expend
considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.
Section 2. Information about the Mission
of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.
Please check the Project Gutenberg web pages for current
donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookball.com

You might also like