Find the Center of a Circle Using Only a Pencil and Straight Edge
I bought a wood lathe recently, and the first time I tried to center some wood, I went through the painful process of remembering how to find the center of a circle. This, despite having had three years of mechanical drawing classes.
Starting with a pencil and straight edge:
- Mark a line on the straight edge that’s a little more than 3/4 of the diameter (height) of the circle. It doesn’t have to be exact.
- Make a mark (M) at the top of the circle. The location of the mark need not be exact.
- Align the straight edge so that the corner is on mark M, and the line on the straight edge touches the right edge of the circle. Draw a line (A) from somewhere above the center of the circle out to it’s edge.
- Repeat on the left side, drawing line B.
- From where line B ends, line up the straight edge so that its corner sits on the end of line B, and its line touches the lower-right-hand edge of the circle. Draw line C along the straight edge, crossing the vertical center line.
- Repeat from the end of line A to the lower-left-hand edge of the circle, and draw line D
- At this point, lines C and D should form an “X” near the bottom of the circle.
- Draw a vertical center line (E) by aligning the straight edge with mark M and the intersection of lines C and D. Start the line above the center, and go all the way to the bottom edge.
- At this point, line E passes through the center vertically, but we need to find the horizontal center.
- From where line E touches the bottom of the circle, align the straight edge so that it crosses line A, and the line on the straight edge touches the upper-right-hand edge of the circle. Draw line F, crossing line A.
- Repeat this on the left side, crossing line B, and drawing line G.
- At this point, there should be an “X” on the left formed by lines B and G, and one on the right formed by lines A and F.
- Align the straight edge across the intersections of the left (B,G) and right (A,F) intersections, and draw the horizontal center line H.
The center of the circle is at the intersection of the vertical (E) and horizontal (H) center lines.
How This Works
Let’s call the distance from the corner of the straight edge to its mark S.
Let’s call the points where the horizontal center line meets the circle’s edges H1 (left) and H2 (right), and the point where the vertical center line meets the bottom V.
If we start at M and walk clockwise around the circle, we would pass through the points as follows: M (start) -> H2 -> V -> H1 –> M (back to start).
The circle’s radius, R, is 1/2 the distance of M -> V or H1 -> H2. The distance from M -> H2 would be SQUARE_ROOT( R^2 + R^2), and the same is true for H2 -> V, V -> H1, and H1 -> M.
If we assume that the radius R is “1 unit” (the actual length is irrelevant), then SQUARE_ROOT(1^2 + 1^2) = SQUARE_ROOT(2), or about 1.41.
If the radius R = “1 unit” then the diameter = 2 * R = “2 units”.
By selecting S such that S is 3/4 of the diameter, 3/4 * 2 = 1.5. Since S>1.41, and we make two consecutive S-length marks around the circle, we know for a fact that 2*S > (M -> H2 -> V).
By doing this twice, once clockwise, and once counterclockwise, we get lines C and D. We can call its intersection point T.
It’s easy to prove that this forms two congruent triangles: (M->A-> T) and (M->B->T). If the line M -> T is the base of both, then because they are congruent, the height of both are the same, which means that M -> T perfectly bisects (A -> B).
Since this line (M -> T) also bisects the equilateral triangle M -> A -> B which is inscribed within the circle, that line must pass through the center of the circle as well.
Carrying M ->T out to the edge of the circle gives us point V.
By drawing a line from V of length S to the edge, we get line F, which crosses line A. We can call this intersection point U.
If we knew where the center of the circle (point O) was located, we could make the congruent triangle argument, that M -> U -> O is congruent to V -> U -> O, and just as with the vertical center line bisecting M->A->B, U -> O would perfectly bisect the larger equilateral triangle M -> U -> V.
On the other side, we draw line G of length S, which crosses line B at point W. Same congruency argument: M -> W -> O is congruent to V -> W -> O, and W -> O bisects equilateral triangle M -> W -> V.
Because M -> U = V -> U we know that M -> U -> V is equilateral, and the same for M -> W -> V. Further, because of the congruency argument, we know that M -> U = M –> W and V -> U = V -> W, and therefore (M -> U -> V) is congruent to (M -> W -> V).
If line U-> O bisects triangle M->U->V, then it must intersect M->V exactly at its center. Same for W->O and triangle M->W->V.
Therefore, W->U passes through the center of both triangles at point O, where W->U intersects M->V.
And therefore, point O must be at the center of the circle, because V->O = M->O, and we know that M->V passes through the center of the circle.
Note that this trick ONLY works if the the mark on the ruler (distance S) is > 1.41 times the radius.
Justin’s Perfect Quiche – Build-Your-Own
I make quiche once or twice per year, and I don’t have a specific recipe that I follow – I usually google for things like portions, temperature, and cooking time.
This year, I decided to take some notes and provide a general quiche framework that will work for any kind of quiche you want.
The goal is to have 4 cups of eggs, cheese, plus other stuff (filler ingredients) that we pour in to a 9″ pie crust. Although a 9″ pie crust will hold about 5 cups, the quiche will rise during the cooking process.
One major tweak from “normal” quiche recipes: Instead of milk, I use sour cream, which has much more fat in it and also significantly improves the flavor. Because sour cream is more dense, I use bread (chopped up) so that you don’t end up with a 2″ thick egg-crete block.
- 9″ Pie Pan, greased, and a sheet pan to bake it on
- Mixing Bowl (I usually skip the mixing bowl, and just mix the ingredients in the 4-cup measure)
- Cutting board and knife as needed for bread and other “filler” ingredients
- 4 Cup measure
- Sautee pan and wooden spatula – if you use cooked ingredients, the pan and spatula are not needed
- 9″ Pie Crust
- 2 to 3 slices of bread
- 8 to 12 eggs
- 1/2 to 3/4 cup of sour cream
- 2 Tbsp of brown mustard
- 1 cup of shredded cheese
- 1 to 2 cups of filler ingredients
- 2 Tbsp of oil or butter to sautee ingredients – if you use cooked ingredients, the oil or butter is not needed
- Salt, pepper, garlic powder, onion powder to taste. About 1/2 teaspoon each.
- For every 4 eggs, use 1 slice of bread and about 1/4 cup of sour cream.
- If you have more filler ingredients, use fewer eggs – minimum of about 8. If you have fewer filler ingredients, you’ll need more eggs, and thus more bread and more sour cream.
- Makes at least 8 portions
- About 20 minutes prep time, and about 1 hour 30 minutes cook time, which includes 15 minutes of resting time, or about 1 hour 50 minutes total.
- For any raw filler ingredients, cut them in to small slices or bite-sized pieces, and sautee them in the sautee pan until tender. They don’t need to be cooked to annihilation, just cooked to the point of tender. Let them cool.
- For any ingredients that are already cooked, such as ham, bacon, or other leftover meat, cut them in to small bite-sized pieces.
- Preheat oven to 375.
- Grease the pie pan and lay out the pie crust, crimping or folding the edges as you would with any other kind of pie.
- Cut the crusts off the bread, and cut the bread in to small cubes.
- Add the following in to the mixing bowl, then whisk until the eggs are fluffy:
- Eggs – at least 8
- Sour cream – at least 1/2 cup
- Brown mustard
- Salt, pepper, and optionally, garlic powder and onion powder.
- Add the following in to the mixing bowl, then stir
- Bread (cubed, with crusts removed)
- Shredded Cheese (about 1 cup)
- Filler ingredients (Pre-cooked and cut in to bite-sized pieces)
- Pour all of this in to a 4 cup measure. At this point, in the mixing bowl, mix up some additional eggs if needed. If you have 3 cups of stuff, you need to add about 4 eggs. If you have 3-1/2 cups, you need to add about 2 eggs, etc…
- At the point where you have 4 full cups of eggs + other stuff mixed and sitting in the 4-cup measure, carefully pour all of it in to the center of the pie crust.
- Place the (now-filled) pie pan on top of the sheet pan (in case it spills over), and place both in the pre-heated oven.
- Bake for 375 for up to 75 minutes. Check the center at about 50 or 60 minutes, and monitor closely until the entire thing is solid. It will rise about 1/2″ to 1″ during the baking process.
- Remove from the oven and let stand for about 15 minutes.
- Cut in to slices and serve.
Let me start off by saying “I HATE FTP!”
It was developed in the early 1970’s, before the Internet was really the Internet, and before the existence of firewalls or any other type of network security. Over the last nearly-50 years, it has picked up so many band-aids that the entire protocol is now just basically one big kludge.
Despite its shortcomings, and despite the availability of newer and far superior file transfer tools, banks, governments, and anyone else with a mainframe continues to use it.
So, unfortunately, people like you and I get stuck supporting it.
If you’re having an FTP problem, or are just morbidly curious to learn about an antiquated protocol, read on…
Bad Design: WinZip – An Annoying Pop-Up Ad from an Irrelevant Product
The company where I am currently employed uses WinZip as its desktop standard for archive software.
This isn’t my preferred option, but whatever.
One minute, I’m cruising around in a spreadsheet, and the next, this pops up:
They company in question has an enterprise license for WinZip, which means that I’m running a fully-licensed copy.
I will cover some of the history of WinZip, and why I think it’s irrelevant, and then I will tell you exactly why I think this pop-up is wrong. I will also make some recommendations for both software designers and corporate desktop administrators.
…and, “Why I think WinZip is irrelevant”
Back in the DOS days, there were competing lossless file compression standards, and that’s still true today.
In the 1980’s and early 90’s, disk space was always at a premium, whether it was deciding what to delete off your hard drive so that you could install a new program, or how many programs you could back up to a floppy disk.
And, before the internet, you connected to Bulletin Board Systems (BBSs) through a very slow modem to find and download software. Smaller files meant that a BBS could host more files, and also, that your download time would be significantly faster.
The first commonly-used compression program for microcomputers was simply called “ARC”. Not only did ARC compress files, but it had the ability to compress multiple files in to a single “archive” file, and later versions could even span multiple floppy disks – handy if you were backing up your hard drive.
Due to its ease of use, single-file archive format, and itself being a small file that was easy to find and download, ARC quickly became standard among BBS operators and users. Every PC in the 80’s had a “C:\UTILS” folder, and ARC was one of the programs inside of it.
Although ARC was commercial software developed by SEA corporation, it was distributed as “shareware” – a license that allowed both individual users and BBS operators to freely “share” the file by copying it, but requested that users send in some money and obtain a proper license if they decided to keep using it. Of course, no one did that, and eventually, SEA released the source code for ARC.
A couple of years later, along came Phil Katz, who wrote a much faster and more efficient implementation of ARC, of course called PKARC, and rather than have both compression and extraction functions within the same executable, Phil Katz split the extraction function in to a separate program called PKXARC. This meant that you could download the much more svelt PKXARC if all you needed to do was extract files without compressing them, but in either case, you would benefit from the much faster code.
PKARC soon became the de facto tool for using ARC files.
Later, Phil Katz co-developed the ZIP file format – the same one that’s in use today. And, like ARC, everyone started using ZIP files, especially popular with BBS operators due to the smaller file sizes and faster extraction routines.
Soon, like ARC, every PC had PKZIP and PKUNZIP in their C:\UTILS folder alongside PKARC and PKXARC. Eventually, people just stopped using ARC altogether.
And thus, Phil Katz built the bulk of the PKWare software empire off of one little shareware utility.
However, PKZIP had one major drawback: It was a command-line program, requiring some knowledge of what a command line is, how to use it, and how to use PKZIP within it.
As operating systems evolved toward Graphical User Interfaces (GUIs) and began to focus on ease-of-use, there was clearly a gap.
You could download a ZIP file from a BBS using your terminal program running in a window, but then you would have to shell out to a command prompt and run some arcane (pun intended) commands to extract the files within it, in to a usable format.
In the early 90’s WinZip emerged as a graphical front-end to PKZip. With PKZip installed, and with WinZip properly installed and configured, a user could simply double-click on a zip file to extract its contents, or drag and drop some files to create a new ZIP file. WinZip handled the user interface, and on the back end, it ran PKZip with the appropriate command-line switches.
Eventually, WinZip adopted a “clean-room” ZIP implementation, and dumped PKZip. Now, there was no complicated dependencies nor configuration. If a user needed to open a zip file, they could simply download and run WinZip as a single program.
As Windows 95 boosted the popularity of home computing, WinZip quickly became much more popular than PKZip. PKWare made a feeble attempt to release a competing GUI product, but it was too-little, too-late. WinZip had been on the market longer, most users were familiar with it, it had better desktop integration, and it was far easier to use.
By the late 90’s, WinZip was one of the first programs you needed to download after any new operating system was installed.
Similar to PKWare, WinZip had a “trialware” license that allowed you to freely use it for a couple of weeks, and then either delete it or license it.
To help drive revenue, unlicensed copies of WinZIp would pop up a friendly reminder. Once you entered a license code, the reminder disappeared. Further, a license was perpetual, and initially allowed for perpetual upgrades. So for about $10 (if I recall), not only could you license WinZip to get rid of the annoying pop-up, but you could also freely download and upgrade to the latest version every couple of months when it was released.
WinZip prospered as it virtually ruled the market. Over time they added new features and updated the GUI, but WinZip was still WinZip.
And then Microsoft released Windows XP, which had built-in support for zip files.
It’s hard to believe that Microsoft turned a blind eye to this lucrative niche for nearly 10 years, but on the other hand, they were probably gun-shy after having recently fought off anti-trust litigation from Netscape. In versions of Windows prior to XP, if you double-click on a ZIP file without WinZip (or another ZIP handler) installed, you more or less get a message that says “what the heck do you want me to do with this??”
Now, with Windows XP and onward, you could double-click a ZIP file to open it, or right-click some files and send them to a “compressed folder”, which is Microsoft’s codename for a ZIP archive file.
Even worse for WinZip, by the time Microsoft released XP, there were Free and Open Source Software (FOSS) alternatives such as WinRAR and 7-Zip. Initially, each of these only supported a proprietary archive format (RAR and 7z respectively), but eventually they both ended up supporting multiple archive formats, including ZIP, and even the advanced features of the ZIP format, such as media spanning and AES encryption.
And, WinZip’s market began to dry up.
Casual users didn’t need to download anything – they simply used the operating system’s built-in ZIP file handler.
Power users could download FOSS utilities for free, such as WinRAR and 7-Zip, and simply avoid both the cost of WinZip and its increasingly clingy, laggy user interface and more frequent and annoying beg-ware pop-ups.
As it turns out, switching from a perpetual to an annual license model was a smart move for WinZip.
Rather than die out like ARC and PKZip, there is just enough recurring revenue from corporate licensees to keep it on life support.
So, despite being completely obsolete, WinZip is still running out there, with it’s ever-more kludgy and annoying user interface, limited features, and annoying pop-ups.
And, companies like the one I work for are still running it, because, hey, it works, and hey, they still have a license for it.
Why Pop-Up Ads are Bad
In case you don’t remember using a computer in the 2000’s, let me describe what it was like:
- “Windows has some updates for you!”
- “Update to the LATEST version of Adobe Flash to view this page!”
- “Adobe Acrobat needs to be updated.”
- “Your virus definitions are out of date.”
- “You’re not running the latest version of WinDVD / WinAMP! Download it now!”
- 10 browser pop-ups for spray tanning you should buy online, software that can clean your PC, stock you must buy immediately, adult websites you HAVE to try right now, the truth about “x”, and whatever else you don’t care about.
Play this every couple of hours on endless repeat while you’re trying to edit a document or watch a movie.
PEOPLE. HATE. POP-UPS.
People hate pop-ups so much that every modern browser has a built-in pop-up blocker – code that specifically stops a website from opening new browser windows.
People hate pop-ups because they are pre-emptive. You have to STOP doing what you WERE doing (which was important to YOU), and click “close” on a useless pop-up. You can’t ignore a pop-up, because it’s right there, blocking whatever you were working on behind it. It’s even worse when you’re typing, because you have to take your hands off the keyboard, which is both slow and distracting.
People HATE them.
So why have a completely random pop-up inside a fully-licensed product??
If I was running the trialware version (if that even still exists), then a pop-up is justified when I first launch the program. “Hey… we see that you still haven’t registered…” OK, fine.
BUT I HAVE registered. It’s fully-licensed. And, I DIDN’T EVEN HAVE WINZIP RUNNING!! So it obviously has hooks in to the scheduler (Microsoft’s biggest architectural mistake, but that’s another story) for the sole purpose of trying to sell me more WinZip crapware, that I can only assume has even MORE pop-ups!
What’s even worse is that I don’t need any of the “new features”, and I don’t want them. I don’t need some crappy product “running tasks in the background” or “sorting through my photos”.
All I need to be able to do is encrypt a ZIP file and read encrypted ZIP files.
BUT, because I’m on a corporate laptop, rather than downloading a superior product like 7-Zip, which is simple, fast, and free, I’m forced to run WinZip and deal with bulky, slow software and random crappy pop-ups. What a user experience!
Just let this sink in for a minute… My recent experiences with WinZip have been so frustrating that I just spent 3 hours of my personal time writing this blog post.
Tips for Corporate Desktop Admins
Why do corporations still use WinZip? Probably one of several reasons:
- You have used it for years. So what. The current version is a kludgy piece of crap. Move on.
- You already own a license. This falls under the sunk cost fallacy. Once an investment significantly diminishes in utility, the best course of action is to STOP SPENDING MONEY ON IT.
- We have to train our users. No, you don’t. The 7-Zip interface is similar to the WinZip classic interface, and anyone who has used a computer within the last decade will figure it out.
- WinZip is secure. So are 7-Zip and WinRAR. But, now that no-one out in “the real world” is running WinZip, finding new vulnerabilities is much more difficult. Existing WinZip deployments could sit on desktops for years in a vulnerable state. In contrast, with 7-Zip being one of the most popular pieces of FOSS of all time, there is lots of active development, and any vulnerability would be quickly identified and patched.
- “Open Source” licensing is questionable. No, it’s not. Have your legal department review and approve the GPL and move on.
- Being open-source, there is little or no support. IT’S AN ARCHIVE UTILITY. HOW MUCH SUPPORT DO YOU REQUIRE? Having said that, there’s probably more support out there for 7-Zip than any Microsoft or IBM product. (Microsoft is the new IBM, they just don’t know it yet.)
- It’s difficult to deploy. You don’t even have to install it. Just copy the files and run it.
- It’s expensive. The “F” in FOSS stands for “Free”.
Tip of the day: DUMP WINZIP. STOP WASTING MONEY ON MAINTENANCE AND LICENSING. MOVE ON TO A SUPERIOR SOFTWARE PRODUCT.
Tip for Software Designers
If you are Microsoft:
If someone is making MILLIONS OF DOLLARS selling an add-on to your flagship operating system, hint, you might want to BUY THEM. Loot the codebase, integrate the functionality, and move on.
If you are a startup company with a niche product:
- Stay within your lane. Don’t over-innovate. Keep the feature set simple.
- Keep the User Interface as simple as possible. People are using your product out of necessity, not preference. They don’t want 15 levels of menus, nor “innovative” user interface elements. Keep it simple and fast.
- Don’t get greedy. You have a niche product, not a “desktop suite”. Charge users a few bucks for each license, and keep the product as simple as possible.
- Pivot when needed. Despite being battered in to the dirt by WinZip, PKWare didn’t go out of business. Currently, they are out of the desktop archiver market, and their current product offering is focused on security.
- Sell out at the top, not the bottom. Because you have a niche software product, someone will eventually come along who sells a better / faster / cheaper product. Once you begin to lose market share, it’s already too late. You WILL eventually have to sell – do you want to sell while your company is dominating the market, or as you walk out of bankruptcy court?
- NO POP-UPS. Remember your place. I don’t “WinZip” on my computer daily. I do a lot of things, and products like WinZip are a very small part of it. The LESS interaction I have, the better.
Enough ranting, I think my points are clear.
If you have a set of things, a permutation is a specific way that you can list those things. Although algorithms exist to list every permutation, most of them rely on recursion – the calling of a function from within itself – which is horribly inefficient.
If you want a non-recursive algorithm that lists every permutation, keep reading…