Although this is "advertised" as a programming challenge, I hope that much of this page will be of interest to a wider audience. While we do, eventually, get to programming challenges, it takes a while to cover the necessary background material, which is, to me, interesting in its own right. And along the way, we visit map making, antique books, and history!
Along the way, we will look at the following, in this order...
Consider the following triangles...
In every case, side AC is 1cm long.
In every case, angle ABC is 90 degrees.
The triangles have different angles at corner CAB, leading to the sides BC and CB being of different lengths in the different triangles.
Suppose we wanted to know how long BC is in each of the triangles, or indeed in any triangle like them. We could, of course, just measure its length. (However, this essay leads to making triangles with a given angle CAB, drawing it from (indirectly) the length of BC... so, for those purposes, we can't draw the angle before we know how long BC is. We can't use measuring BC after we've drawn the angle when we're drawing it that way!)
Trigonometry will save our day. Trigonometry, and some tables which were universally available before about 1990. Today, in place of the tables, we just use a calculator, which will give us the numbers we previously obtained from the tables. (The calculator probably just looks the number up in a table inside its little silicon "brain".)
You don't need to know much trigonometry, and the bit you do need, I will explain in a minute.
If you know trigonometry you will understand what people mean by the following:
"The sine of 20 is 0.34"
A trigonometrist(if that's a word!) would agree that from the above, you would know that...
"A triangle ABC like the ones we were talking about, i.e. angle ABC 90 degrees, side AC 1 cm long, if its angle CAB was 20 degrees, then side BC would be 0.34 cm high."
We'll review that in a moment, but first: Where did the 0.34 come from? Either from a table (Go down the "angle" column to the "20 degrees" row, and then look in the sine column, where you will find 0.34.)... or it can be obtained from a calculator if you ask "What is the sine of 20 degrees?" (You can also just type that question into Google.)
"Sine" is often abbreviated "sin", but still pronounced as if the "e" is present. Rhymes with "fine".
Strictly speaking, sines are the numbers you get from triangles like the ones we've been considering. The angle at corner B (angle "ABC") must be 90 degrees. If it is, the sine of the angle at corner A (angle "CAB") is "the length of BC divided by the length of AC". As such, it is a ratio, and thus has no units... just as the ratio between the diameter of a circle and its circumference is about 3.1415 (aka "pi"), also with no units.
We are starting with a simple case, where AC is 1 cm long. Regardless of the length of AC, in a triangle such as we have been discussing, if the angle at A (angle "CAB") is 20 degrees, the sine of 20 degrees is 0.34, and if you solve the equations you can set up, you will find that BC will be 0.34 cm long when AC is 1cm. You obtain this from the 0.34 which a table will tell you is the sine of 20 degrees.
I said we would discuss....
"If you had a triangle ABC (like the ones we were talking about), and angle CAB were 20 degrees, then side BC would be 0.34 cm high."
Just to stress some of the bits of "like the ones..." that which are important:
Side AC will only be 0.34 cm long if...
So far so good?
Happily, even if AC is not 1cm long, we can still find the length of BC if we know the sine of the angle at CAB: If AC were 2cm long, then BC would be twice 0.34, i.e. 0.68. If AC were 10cm long, then BC would be 3.4cm long, and so on. (BC=sine(CAB)*AC)
Well, if I were to just tell you, it would spoil the fun you can have by solving the following programming challenge. Suffice it to say that I haven't inflicted all of the above on you at random.
Before recent innovations in map making, and the possibility of using satellite images and GPS, maps were created by drawing eye-wateringly large numbers of angles. The more accurately they were drawn, the better the resulting map.
From the angles, points could be put on the map, e.g. the place where you should find the top of a hill. Often, the angles gave rise to a series of points, for instance if you wanted to show the outline of a 10 hectare island in a lake, you put poles every 100m along the shore of the island, measured angles connected to those poles, used the angles to plot a series points on your map. "Connect the dots", and you have your island on your map! I did say that an eye-watering number of angles were involved, didn't I? I never said making maps was easy.
Ha! You already know: Use a protractor.
Well, you could. But I'm going to show you an other way... a better way, for some circumstances. (Unless you have an expensive set of well made protractors, in various sizes, my technique may allow you to draw angles more precisely.)
One technique for drawing an angle accurately is as follows. I first came across it in a book from 1755. The link will take you to images from that book explaining things similar to those explained here! (The book's contents, especially the diagrams, are quite lovely, apart from anything else. Go on... take a break from this hard stuff.)
Suppose you had the following, with AB already drawn, and the task of drawing AC above it (i.e. roughly where the dotted line lies), making CAB as close to 40 degrees as you could make it?
If you have a circle-drawing compass, a ruler, and two "special numbers", it is easy.
The following diagram tells the story, but it is told again in words below, if the finished diagram is too much to digest in one step. The numbers in circles tell you the sequence you need to follow. The 6.8 is one of the "special numbers" I said you'd need. It is only right for a 40 degree CAB, and only if the other number is 10. The "other number" is the radius of the arc centered on A shown in the following, created as step 2 of the process. (More on where "the numbers" come from later!)
Note: We don't care where B is, as long as it is at least 10cm from A. We do not care where D is, at all, even if you might think we would...
We start by drawing AB, a little more than 10cm long. 11cm will do.
Set a compass so that the point and the pencil tip are 10cm apart. Put the point of the compass on A. Draw an arc upwards from AB until you have gone past the point where AC would cross the arc you are drawing. (Judge it by eye... you know where a AC would have to go to make a 45 degree CAB, don't you?)
Re-set the distance between the compass point and the pencil to 6.8cm
Put the point of the compass on E, the point where AB and the arc you made earlier cross. Draw a short arc crossing the first arc, above AB. "C" is at the point where the two arcs intersect.
Draw a line from A to C (where the two arcs cross), and you will have finished your diagram in which CAB is 40 degrees. (Throughout this, I often mean "line segment" when I say "line". Sloppy. Tsk. Would the extra words help, or just clutter? I even use "line" for "ray" in a few places, I suspect.)
Simple! Easy to do accurately! IF you have "the numbers". (6.8 and 10, in this case.)
Take a break, and come back with a fresh piece of paper, the ruler, the compass and 10cm (radius of arc from A) and 6.8 (radius of arc from E), and see if you can draw the 40 degree angle. If you can, then perhaps you really understood what I wrote! Hurrah!
If you think back to what I said about sines earlier, and if you are given a table of sines (or a calculator), and the length of the radius you are to use for the first arc, you should be able to tell me, for any angle (CAB) up to 90 degrees, what "the other number" (the radius of the second arc) needs to be, to draw CAB accurately.
To help you check if you have got the right answer, here are "the numbers" for a selection of cases. "The number" is given its proper name, "chord", in the table headings. A chord is a straight line segment between two points on a circle. (We will be using a compass, set to the required chord, with it's point on one of the ends of the chord, to find quickly and accurately where the other end of the chord lies on the circle.)
If you "give up"(sad!), I have the answer written out for you, but do try to give yourself the fun of figuring it out for yourself. Revisit the material at the top of the page. Hint: it is no coincidence that I illustrated the angle drawing technique with a 40 degree angle after explaining sines with a 20 degree angle.
Still stuck? Too impatient to wait for your brain to produce the answer? It will, you know, if you just take a break, "stop thinking" about the problem. Your brain's capacity to work on things in the background, down at some sub-conscious level, is amazing! Give it a chance. Want the answer now? Oh well... here's a link to the answer.
Once you've figured out the answer to why angles can be drawn thus, either by yourself, or by going to the page with the answer on it, we come to....
Who cares? Well, today, few people, as far as I know. I found the whole thing interesting, amusing. I hope you have too, given the reading you've dine to get here.
Before we started letting computers do everything for us, whenever maps were being made, the people who drew them from the measurements made on the site by the surveyors spent their day trying to draw many, many accurate angles. And for each map, they probably used several different arcs of different radii. Today, map makers just feed the angles into a computer. But behind the map-drawing program, there was a programmer who knew what to tell the computer to do with the numbers.
The first programming challenge is as follows:
(Not very difficult, really.)
Write a small application with at least two edit boxes and one label. (Some other labels to make everything clear would be a sign of your maturity as a programmer.)
Your application would be for the use of a map drawer. He or she would enter the size of the radius they were using, and then repeatedly enter a new value in the "Angle" edit box. As soon as any number changes, the number shown for "length of chord" should change.
For extra credit: although the system doesn't actually break down when you have numbers outside the following ranges, have your application present "Please enter an angle from 0 to 90 degrees" or "Please enter a radius from 1 to 100cm" whenever the user enters something outside either range.
Now... just to see if it all works, and to show you a few more things which I find neat. We're going to make a simple map, the old fashioned way.
If this description of how to draw a map "doesn't work for you", I have a second, older, site where I tried to explain map drawing with angles once before. Maybe it will be more to your way of thinking.
To start drawing a map the old fashioned way entailed going out to the place you wanted to map, instead of merely obtaining an aerial photograph. For the sake of our exercise, we are going to say that we want to map a medium sized, four sided field. And that I have a friend who will go out to it and make the measurements we need for us.
He will stand in at least two corners of the field, and, from those spots, measure various angles.
Let's say that he started by going to "A", and measured the two angles shown in blue in the (upper) rough sketch of our field (to the right)
He would then have gone to "B" and measured the two angles shown in red in the lower rough sketch. (Don't expect the finished map to look exactly like the field as sketched. The sketch is just to specify where "A", "B", "C" and "D" are.)
The sketch was drawn in the conventional orientation: D is the northwest corner of the field, B the southeast corner.
As we go along, I will tell you the angles our friend measured for us. In passing, I will mention that he measured the angles using the theodolite shown to the left, a work of Victorian engineering art. (And, just as I have this page about how you can draw angles, make maps, etc, I have also created some pages about how you could make your own theodolite... one of remarkable precision, for what it would cost you in materials and time.)
Take a sheet of paper at least 25cm x 18cm, i.e. a sheet of "letter" or A4 paper.
Near the bottom edge, roughly centered, draw a 16 cm line. Mark the left hand end "A" and the right hand end "B". That line stands for the southern edge of the field. (North is, as usual, "up" on our map. "Up" is a silly designation, when you think about it... unless you have the map pinned to a wall. But... "You know what I mean"?)
Congratulations! You have started a map of the four sided field my surveyor friend measured for us. Now we will put point "C" on our map, representing the upper right hand corner of the field, the NE corner.
My surveyor friend stood at the corner represented by A on your map. He measured CAB, and found it to be 60 degrees. (A bit of a coincidence, but this is and academic exercise, after all. Would you rather I used a real field, with CAB 26.9 degrees?)
Then he walked over to the corner represented by B on your map, and measured angle ABC, and found it was 90 degrees.
Draw those two angles on your map. (Just use a protractor, if you wish.) See how the lines (AC and BC) cross towards the upper right of the page? That point on your map corresponds to the northeastern corner of the real-world field. You've found were to put "C" on the map!
Whew! Seems like a lot of work for three points. Sigh
AB could have been any length. I told you to make it 16cm long so that your map wouldn't spill off the edges of the paper.
It could have been any length. C (assuming it made it onto the page!) would be in "the right" place.
But the length of AB determines the scale of the whole map. My helpful imaginary field happens to be 160 meters along it's southern side. So 1cm on our map shows 10m in the real world.
If you were drawing a map "for real", you would probably want to know the scale, and thus, besides measuring angles, as we illustrated above, you would need to measure one distance. Once you have one of the distances, the rest "take care of themselves", although map makers usually take extra distance measurements, as a check on the map's accuracy.
So far: We have a map showing three corners of the field. To get the fourth corner, my friend measured two other angles: DAB and ABD. They were 90 degrees and 80 degrees respectively... the field wasn't quite rectangular, you see.
Draw in those two angles. Where they cross gives you the location of the field's NW corner, "D".
Here's what your map should look like, if I succeeded in explaining what you had to do...
A lot of work a map of only four points. And yet, that is the basis of a crucial element at the heart of how maps were produced before the days of aerial photography.
(Going further...) In the real world, the workload gets worse. Our four point map needed four angles and a distance. But, real-world, if you were drawing such a map, you would probably also go to C and measure BCA and ACD. Let's say those angles measured 50 degrees and 36 degrees respectively. Try to draw those in on your map. CA should pass neatly through where AD and AB crossed. When this happens, it suggests that most of your measurements in the field and your drawing were accurate.
Now try to draw angle "ACD" as 36 degrees. If you've plotted everything to date well, the angle on your map that is actually ACD, according to where you have A and C and D will not be 36 degrees. But what if when the surveyor was in the field, he recorded ACD as 36 degrees?
To help us think about that, draw a 36 degree angle. Put the apex at C. Make one arm lie on AC. Put "AD" where it must be to make the angle 36 degrees. It should pass near where you have D on your map. Near, but not through. At this point you should have three lines which nearly cross near where you thought D was when you had just two lines. The fact that the three lines to not pass cleanly through one point tells you that an angle was mis-measured, or mis-drawn.
You can't really say which angle, but that fact that your placement of C seemed to be accurate (from the fact that three lines DO cross there, if you've drawn the map accurately) gives you a hint.
In order to build in this "checking" mechanism, old-time surveyors measured more angles than were "needed".
That concludes "Going further".
Although I said it once before, I think it bears repeating here: If the above didn't make complete sense, I have a second, older, site where I tried to explain map drawing with angles once before. Maybe looking at that would consolidate your understanding? But be sure to come back here for the next bit, which isn't present at the older site. If you use the link, the older site will open in a new tab or window, making getting back easy... you just close the other tab or window.
In the real world, you don't always have the nice, easy circumstances which we imagined for our example of the map of the field. Remember: You need at least two places you can get to. You have to be able to see one from the other. You have to be able to see the thing you want to put on your map from both of them. You need to be able to measure how far apart your "places you can get to" are, if you want to draw a map with a scale. And that's to draw a map of three points!
In the 1800s, the British completed a vast project to map many, many, many, points in India. (Previously, the French had done something similar on a smaller scale within their own borders, and the British had "practiced" with a triangulation of Britain, before embarking on the work in India.)
Man's journey to the moon was pretty impressive. In some ways, I am as impressed by the Great Trigonometrical Survey of India. The volume of work done, the care with which it was done, and the logistics involved are extraordinary. The link above will take you to a page I've written about the survey. (It too will open in a new window or tab, leaving this as it is, to come back to.)
My write up of the second programming challenge has some material which I wanted to make available to readers of another page, and in any case this page had become quite long. (If that's not a problem for you, count your lucky stars. Not everyone has a fast internet connection, you know!)
For the second programming challenge, and some data to use for testing your program, click on the link at the start of this sentence.
Have you heard of Flattr? Great new idea to make it easy for you to send small thank you$ to people who provide Good Stuff on the web. If you want to send $$erious thank yous, there are better ways, but for a small "tip" here and there, Flattr ticks a lot of boxes which no one else has found a way to do yet. Please at least check out my introduction to Flattr, if you haven't heard of it? "No obligation", as they say!Programming challenge/ map drawing/ drawing angles.
Search across all my sites with the Google search button at the top of the page the link will take you to.
Search just this site without using forms,
Or... again to search just this site, use...
The search engine merely looks for the words you type, so....
*! Spell them properly !*
Don't bother with "How do I get rich?" That will merely return pages with "how", "do", "I", "get" and "rich".
I have other sites. My Google custom search button will include things from them....
One of my SheepdogGuides pages.
My site at Arunet.
--Click here to visit editor's freeware, shareware page.--
This page's editor, Tom Boyd, will be pleased if you get in touch by email.
Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes. There were two "unknown attributes" in Google+ button code plus 4 in the Flattr. Sigh.