Turtles and More

Kina
Turtle graphics. This to me resembles a Kina or Sea Urchin

My wife recently became interested in the Spirograph (™) system. Since her birthday was coming up, so did I, for obvious reasons. If you have never come across Spirograph (™) I can highly recommend it, as it enables the production of glorious swirls and spirals, using a system of toothed wheels and other shapes. When you use multicoloured pen, the results can be amazing.

Of course, I had to translate this interest into the computer sphere, and I immediately recalled “Turtle Graphics” which I have used before. It is possible to create graphics very similar to the Spirograph (™) designs very simply with Turtle Graphics.

Trefoil
This resembles the sort of things generated by Spirograph (TM)

Turtle Graphics have a long history, stretching back at least to the educational programming language Logo. Although variations of the original Logo language exist, they are fairly rare, but the concept of Turtle Graphics, where a cursor (sometimes shown as the image of a cartoon turtle) draws a line on a page, still exists. The turtle can be directed to move in a particular way, based on instructions by the programmer.

For instance the turtle can be instructed to move forward a certain distance, turn right through 90°, and repeat this process three times. The result is a small square. Or the turtle could be instructed to move forward and turn only 60°, repeating this 5 times to draw a hexagon. Using simple instructions like this allow the drawing of practically anything.

Square and Hexagonal spirals
Square and hexagonal spirals drawn by Turtle Graphics

I use an implementation of Turtle Graphics in the turtle module of the Python programming language but it is probably available for other programming languages. Python is probably an easy language to learn from scratch than Logo, and in addition Python can be used for many other things than Turtle Graphics. Python is available for Windows, OS/X, and Linux/Unix, and for several other older or less well known platforms.

Where things become interesting is when the looping abilities of Python are used to enhance a program. If the programmer gets the turtle to draw a square, then makes the turtle turn a little and repeats the process, the result is a circular pattern. Starting with a more interesting shape can produce some interesting patterns.

Rotated Square - Turtle graphics
Rotated Square – Turtle graphics

After a while, though, the patterns begin to seem very similar to one another. One way to add a bit of variation is to use the ability to make the turtle move to a specific position, drawing a line on the way. As an example, consider a stick hinged to another stick, much like a nunchaku. If one stick rotates as a constant speed and the second stick rotates at some multiple of that, then the end of the second stick traces out a complex curve.

Flower shape
Flower shape – turtle graphics

In Python this can be expressed like this:

x = int(a * math.sin(math.radians(c * i)) + b * math.sin(math.radians(d * i)))
y = int(a * math.cos(math.radians(c * i)) + b * math.cos(math.radians(d * i)))

where c and d are the rates of rotation of the two sticks and and b are the lengths of the stick. i is a counter that causes the two sticks to rotate. If the turtle is moved to the position x, y, a line is drawn from the previous position, and a curve is drawn.

The fun part is varying the various parameters, a, b, c, d, to see what effect that has. The type of curve that is created here is an epicycloid. For larger values of c and d the curves resemble the familiar shapes generated by Spirograph (™).

Epitrochoids
Epitrochoids

The equations above use the same constants in each equation. If the constant are different, some very interesting shapes appear, but I’m not going to go into that here. Suffice it to say, I got distracted from writing this post by playing around with those constants!

The above equations do tend to produce curves with radial symmetry, but there is another method that can be used to produce other curves, this time with rotational symmetry. For instance, a curve can be generated by moving to new point depending on the latest move. This process is then iterative.

Gravity Wave - turtle graphics
Gravity Wave turtle graphics

For instance, the next position could be determined by turning through an angle and move forward a little more than the last time. Something like this snippet of code would do that:

for i in range(1, 200):
t.forward(a)
t.pendown()

t.left(c)
a = a + 1
c = c + 10

This brings up a point of interest. If you run code like this, ensure that you don’t stop it too soon. This code causes the turtle to spin and draw in a small area for a while, and then fly off. However it quickly starts to spin again in a relatively small area before once more shooting off again. Evidently it repeats this process as it continues to move off in a particular direction.

Turtle graphics - a complex curve from a simple equation
Turtle graphics – a complex curve from a simple equation

Another use of turtle graphics is to draw graphs of functions, much like we learnt to do in school with pencil and squared paper. One such function is the cycloid function:

x = r(t – sine(t))

y = r(1 – cosine))

This function describes the motion of a wheel rolling along a level surface and can easily be translated into Python. More generally it is the equation of a radius of a circle rolling along a straight line. If a different point is picked, such a point on a radius inside the circle or a point outside the circle on the radius extended, a family of curves can be generated.

Cycloid curve - turtle graphics
Cycloid curve – turtle graphics

Finally, a really technical example. An equation like the following is called a dynamic equation. Each new ‘x’ is generated from the equation using the previous ‘x’. If this process is repeated many times, then depending on the value of ‘r’, the new value of ‘x’ may become ever closer to the previous value of ‘x’.

x(n+1) = rx(n)(1 – x(n))

If the value of ‘r’ is bigger than a certain value and less than another value, then ‘x’ flip-flops between two values. If the value of ‘r’ is bigger than the other value, and smaller than yet another value then ‘x’ rotates between 4 values. This doubling happens again and again in a “period doubling cascade“.

Turtle graphics - electron orbitals
Turtle graphics – electron orbitals

I’ve written a turtle program to demonstrate this. First a value for ‘r’ is chosen, then the equation is repeated applied 1,000 times, and the next 100 results are plotted, x against r. In the end result, the period doubling can easily be seen, although after a few doubling, the results become messy (which may be related to the accuracy and validity of my equations, and the various conversion between float and integer types).

Period doubling
The “fig tree” curve calculated in Python and plotted by Turtle Graphics.

Upgrading


Embed from Getty Images

I’ve just upgraded my desktop computer system. I’ve replaced the CPU, motherboard, RAM, power supply unit, and disk drive. In fact what I’ve really done is build a new computer in the existing case, keeping only my keyboard, mouse and monitor.

I’ve not had any problems, apart from the fact that the pesky little screws that hold things together seem smaller and more fiddly than I remember, but that may just be my ageing fingers.

English: Sony NEWS UNIX workstation. Left view...
English: Sony NEWS UNIX workstation. Left view with the top open. The top is held by 6 screws, 2 on the back and 2 on each side. On the left side we can see the only cooling fan. (Photo credit: Wikipedia)

Incidentally I replaced the existing hard disk drive with a solid state drive or SSD. This is neither disk shaped nor does it have any moving parts, so its name is a bit misleading.

I’d had the previous computer for several years, so why did I replace it? Well, it was getting a little slow and some things ran very slowly on it. When I did a backup it would slow almost to a crawl. Its slowness was my fault really as I was trying to run far too much stuff on it. If I merely browsed the Internet and received and sent mail, and got rid of all the other baggage that I had acquired, it would probably have sufficed.

A modest junk box
A modest junk box (Photo credit: Wikipedia)

But where’s the fun in that! Having been system administrator in the past, I see interesting things coming through, like programs that simulate the running of an Android phone, so that you can write and test them on your desktop,. Wow! Now all I need is an idea for a killer app that can make me buckets of money.

So that went on the desktop, and I tried it out and lo! It worked fine. Then I moved on to something else and the killer app never got written. That seems to be the way that it goes with me – I see something cool, install it, and get it working, but once I get a handle on how it behaves, I lose interest.

English: Wikipedia Android app
English: Wikipedia Android app (Photo credit: Wikipedia)

I have nothing but admiration for people who have an idea, who then program it up, put it out there for people to try, and then deal with the inevitable bug reports and requests for enhancements and changes. Sometimes they modify and support the programs that they write for decades. Of course if they get bored with the whole thing, they can walk away from their baby and either the program becomes “abandonware” or someone else takes up the baton.

I can program though. I’ve written and supported programs and scripts which I’ve written for my job as systems administrator, and even at home I’ve written backup scripts and programs which are useful and, for the moment, complete, but I’ve got dozens of others which I started but did not complete for some reason or other.


Embed from Getty Images

As an example, this blog uses WordPress as a platform. WordPress comes in two forms. There is the usual WordPress service, referred to as “WordPress.com” and there is “WordPress.org“.

The “dot org” version is an Open Source project with hundreds of volunteers writing code, packaging and otherwise making WordPress available to anyone wants to download it and use it on the computers that they operate and use.

Screenshot of WordPress interface (wordpress i...
Screenshot of WordPress interface (wordpress is under the GPL) (Photo credit: Wikipedia)

However, many people don’t want to do download and run it themselves, either because they don’t have that sort of access to the computers that they use, or they are not technically competent enough, so the “dot com” version of the program is provided for people who simply want to use WordPress and not maintain it.

I set up this blog on WordPress.com initially, but wondered if it would be a good idea to run the WordPress.org version instead. So I downloaded it and installed it, and bingo! A clone of WordPress.com. Which was OK, but then I was faced with the need to find somewhere visible to host it – it’s no good having a blog if people can’t see it!

Multiple racks of servers
Multiple racks of servers (Photo credit: Wikipedia)

In the end I decided to stay with WordPress.com as I didn’t need anything different from that version, and using WordPress.com avoid the hosting hassles. For a simple blog, without any esoteric bells and whistles, it is ideal. It can also be used for more complex situations, provided they don’t need changes to the core code.

Incidentally I started out with a Drupal site. I love Drupal and still have a Drupal site on my computer, which I tinker with occasionally. It’s a much more complex beast than WordPress (though WordPress is very flexible and extendable), but in the end, I don’t need the complexities at this time, so I moved to WordPress. One is not better than the other, they are just different.

drupal icon, svg version
drupal icon, svg version (Photo credit: Wikipedia)

Of course, I’ve tried many other content management or blogging tools and frameworks. A framework can be thought of as a “do it yourself” type of website building tool, a few steps up from writing HTML, and several steps below a complete content management or blogging system.

All the discarded and forgotten stuff on my computer was obviously slowing it down, but arguably more importantly, technology has moved on. The old CPU had a single core, whereas the new one has ten! Two gigabytes of memory was proving restrictive. The disks were old and slow.

English: A portion of a DECsystem-1090 showing...
English: A portion of a DECsystem-1090 showing the KL10 CPU and MH10 memory cabinets. Suomi: Osa DECsystem-1090-tietokonetta. Kuvassa koneen KL10-pääyksikkö (kolme ensimmäistä kabinettia?) ja useita MH10-muistikabinetteja. (Photo credit: Wikipedia)

So the upgrade happened and I’m very pleased with it. The CPU (currently) barely breaks into a canter. The RAM is extensive, and I’m sure there are bits that haven’t been touched! Above all the new SSD is fast and my browser opens in a snap. No doubt I’ll think of things to eventually slow it down, but for the moment it is great. All the crud is gone, but I still have it backed up. Once a sysadmin always a sysadmin – always take backups of your backups and never throw anything away!

Just About There
Just About There (Photo credit: Wikipedia)

Above all it is quiet! There is no disk noise, and the CPU fan is also quiet. I was telling my daughter how quiet it was and sure enough we couldn’t hear it running. OK, there was a bit of ambient noise from the grand-rats and the dog, but it was quiet. It wasn’t until they had gone that I discovered that it was actually switched off! But it really is that quiet.

English: It's not normally this quiet.
English: It’s not normally this quiet. (Photo credit: Wikipedia)

Updates and Upgrades


Embed from Getty Images

I have currently got computer issues so this week’s posting has not been written.😱 I’m writing this as a placeholder until I can catch up. The subject will be, as above, “upgrades”.

One of the joys of using a computer is applying the updates that come out for the operating system and applications. With a multitude of computing devices that a person has these days, this can be time consuming.


Embed from Getty Images

On desktop computers running the Windows operating system, this can be made pretty much invisible, but on phones and tablets, and on other operating systems this can be a chore.

Most updates are for applications and not for the operating system itself, but often a user may have no idea of the difference. A tech-savvy person asks what operating system a user is using, expecting to hear “8.1” or “7” or even “Vista” or “XP” he/she is surprised to be told “Internet Explorer” or even “GMail”.

Screenshot of Android 4 on Galaxy Nexus
Screenshot of Android 4 on Galaxy Nexus (Photo credit: Wikipedia)

An application upgrade is usually benign and the user will not notice any difference as the changes will be behind the scenes, but now and then a user visible change is made and the user often thinks that his machine is broken.

Geeks often have a quiet snigger at this but it is a bit unfair. The user is using the computer as a tool, and tools as a rule do not change. A spanner doesn’t suddenly overnight change from Imperial sizes to Metric sizes and the computer user is not unreasonable in expecting his/her computer to not suddenly change.


Embed from Getty Images

Some updates however are far from benign, causing data loss or serious computer issues. Those not of the “Windows World” frequently blame Microsoft for such issues, but when there are billions of users out there, using different hardware configurations, it is not surprising that things occasionally break. Nastily!

When I talk about the “Windows World”, I am talking about the users of the Microsoft Windows operating system, by far the largest group of computer users. Until recently the other major groups of users were the “Mac World” and the “Linux World”, but more recently these have been joined by the “Apple World” and the “Android World”.


Embed from Getty Images

Since Macs are made by Apple, arguable the “Mac World” and the “Apple World” are the same, but by the “Apple World” I mean those users of iPads, iPhones and even the iPod. The “Mac World” refers to users of desktop and laptop Macintosh computers.

The application updates are arguably more visible on handheld devices and owners of such devices may be notified two or more times a week that such and such an app needs updating or has been automatically updated. It’s not too much of an issue, but naive users may not be performing the necessary couple of clicks to update the apps.


Embed from Getty Images

Of course, by taking this course they may be missing out on security and stability fixes or fixes for serious bugs, to them the risk of fiddling with their devices may seem higher, and I can understand that.

Computer users, especially naive users, develop a pattern of working, a “workflow” if you like that suits them and works around any bugs or issues in their apps. No wonder they get furious when their workflow is disrupted! In one case, (reputedly) a computer user who had her machine updated was outraged that her icon had “gone”, when in fact it had moved to a different line.


Embed from Getty Images

It’s easy to laugh at such happenings, but really, one should try to see here point of view. The icon did something when she clicked. It had moved and even if it looked the same in its new position, she could not be sure that it would do the same thing.

If a more sophisticated user were to notice that an icon had moved, they would probably assume that it would work the same, and in 99.99…. per cent of the time they would be correct. But the naive user did not know the odds and of course, she was correct in that there was a non-zero possibility that the icon would behave differently.


Embed from Getty Images

There is a subtle difference between an update and an upgrade, I believe. I don’t know if it is an official definition, but when updates are mentioned I feel that such changes should be minor and with little visible impact. Updates may be changes made to applications and to the operating system itself, but the key feature is that they do change functionality or user workflow fundamentally, and would predominately be bug fixes or small enhancements.

Upgrades on the other hand, would be more fundamental changes and may result in majorly changed functionality and workflows, like the changes between Windows 7 and Windows 8. The change between Windows 8 and Windows 8.1 would probably be an update rather than an upgrade, but this one is marginal.

Tux, the Linux penguin
Tux, the Linux penguin (Photo credit: Wikipedia)

I’m in the “Linux World” and my desktop runs Ubuntu. I’ve recently upgraded to version 14.10 (also known as Utopic Unicorn) and I had a number of issues, none of which was a show stopper, but some of which were annoying. I’ve previously upgraded successfully with few issues, but maybe I accumulated too much junk.

I definitely don’t think that the issue is with Utopic Unicorn as the forums don’t have posts which relate to my issues, which they would if it were a general issue, so it is something related to my own setup, most likely.

Official Ubuntu circle with wordmark. Replace ...
Official Ubuntu circle with wordmark. Replace File:Former Ubuntu logo.svg. Español: logo de Ubuntu + marca denominativa Français : Logo officiel d’Ubuntu. Remplace File:Former Ubuntu logo.svg. (Photo credit: Wikipedia)

So I’ve reinstalled, which has taken some time. There is one niggly issue that should be fixed shortly, but I was without access to some essentials, like Facebook and GMail on my desktop machine, for a day or two. Fortunately I was able to access these absolute essentials on my tablet (Android) and phone (also Android).

During this time I had to fix my daughter in law’s Windows laptop and upgrade the iPad to the newest version of IOS. Now my Android phone wants to upgrade to Android version 5.0 (also known as “Lollipop”). I think that I will wait for version 5.0.1 or 5.1!


Embed from Getty Images