aemkei's xor patterns

Alien Art Drawn With Surprisingly Simple Math

Programmer [aemkei] Tweeted the formula (x ^ y) % 9 alongside code for more “alien art”. But how can a formula as simple as (x ^ y) % 9 result in a complex design? The combination of Bitwise XOR (^) and Modulo (%) generate a repeating pattern that’s still complex enough to satisfy the eye, and it’s ok if that doesn’t sound like an explanation. Bitwise operations are useful when working with memory and shift registers, but also worth learning if you want to drive lines or matrices of LEDs or interpret combinations of multiple switches, or in this case a great way to throw an interesting test pattern up on a new flip-dot display or low-res LED matrix. Are you into it? We are, so let’s jump in.

XOR Truth Table
0b00 0b01 0b10 0b11
0b00 0b00 0b01 0b10 0b11
0b01 0b01 0b00 0b11 0b10
0b10 0b10 0b11 0b00 0b01
0b11 0b11 0b10 0b01 0b00

Bitwise XOR compares each binary digit of the two inputs. The XOR returns a 1 when only one of the two digits is a 1, otherwise, it returns a zero for that position. Let’s say the coordinates were 3, 2. Converted to binary we have 0b11 and 0b10. From this truth table, we can see the most-significant digits are both 1, returning a 0, while only one of the least-significant digits is a 1, so the comparison returns a 1.

Moving onto the %, which is the Modulo operator has nothing to do with percentages. This operator divides two numbers and returns the remainder if any. Take 9 % 5. When dividing 9 by 5, 5 goes in once with a remainder of 4 so 9 % 5 = 4. Now our original formula from the top will draw a black box for every ninth number except that the bitwise XOR throws a wrench into that count, varying how often a number divisible by 9 appears and supplying the complexity necessary for these awesome patterns.

detail of aemkei's xor patterns

What are the most interesting designs can you create in a simple formula?

Imaging The Past With Time-Travel Rephotography

Have you ever noticed that people in old photographs looks a bit weird? Deep wrinkles, sunken cheeks, and exaggerated blemishes are commonplace in photos taken up to the early 20th century. Surely not everybody looked like this, right? Maybe it was an odd makeup trend — was it just a fashionable look back then?

Not quite — it turns out that the culprit here is the film itself. The earliest glass-plate emulsions used in photography were only sensitive to the highest-frequency light, that which fell in the blue to ultraviolet range. Perhaps unsurprisingly, when combined with the fact that humans have red blood, this posed a real problem. While some of the historical figures we see in old photos may have benefited from an improved skincare regimen, the primary source of their haunting visage was that the photographic techniques available at the time were simply incapable of capturing skin properly. This lead to the sharp creases and dark lips we’re so used to seeing.

Of course, primitive film isn’t the only thing separating antique photos from the 42 megapixel behemoths that your camera can take nowadays. Film processing steps had the potential to introduce dust and other blemishes to the image, and over time the prints can fade and age in a variety of ways that depend upon the chemicals they were processed in. When rolled together, all of these factors make it difficult to paint an accurate portrait of some of history’s famous faces. Before you start to worry that you’ll never know just what Abraham Lincoln looked like, you might consider taking a stab at Time-Travel Rephotography.

Amazingly, Time-Travel Rephotography is a technique that actually lives up to how cool its name is. It uses a neural network (specifically, the StyleGAN2 framework) to take an old photo and project it into the space of high-res modern photos the network was trained on. This allows it to perform colorization, skin correction, upscaling, and various noise reduction and filtering operations in a single step which outputs remarkable results. Make sure you check out the project’s website to see some of the outputs at full-resolution.

We’ve seen AI upscaling before, but this project takes it to the next level by completely restoring antique photographs. We’re left wondering what techniques will be available 100 years from now to restore JPEGs stored way back in 2021, bringing them up to “modern” viewing standards.

Thanks to [Gus] for the tip!

Continue reading “Imaging The Past With Time-Travel Rephotography”

Why Pendulums Sync Up, And Other Mysteries Explained

If you’ve ever seen fireflies flashing together at night, you’ve witnessed the glory of synchronisation. In a new video, [Veritasium] examines some of the mechanisms in nature that help create order out of chaos. 

The story begins back in 1665, when [Christiaan Huygens] discovered that two pendulum clocks hanging from the same wooden beam would spontaneously synchronise over a period of time. The same principle is then demonstrated with metronomes – an experiment readily recreated in the home. Other systems that show this same eerie coordiation are then explored – from tidally locked moons orbiting around planets (like ours!), to chemical oscillators discovered by Soviet scientists during the cold war. There’s also a great explanation of the problems faced by the London Millennium Bridge, which swayed wildly under heavy foot traffic as it induced pedestrians to walk in sync.

Overall, it’s a look at some of the action behind the scenes that ties seemingly independent systems together. Learning about such things can prove useful too – it might even help you solve real world problems in your machine shop! Video after the break.

Continue reading “Why Pendulums Sync Up, And Other Mysteries Explained”

Space Shuttle Program: 40th Anniversary Of The First Launch Of Columbia

For those who grew up watching the endless coverage of the Apollo program in the 60s and 70s, the sight of OV-102, better known as the Space Shuttle Columbia, perched on pad 39A at the Kennedy Space Center was somewhat disconcerting. Compared to the sleek lines of a Saturn V rocket, the spacecraft on display on April 12, 1981, seemed an ungainly beast. It looked like an airplane that had been tacked onto a grain silo, with a couple of roman candles attached to it for good measure. Everything about it seemed the opposite of what we’d come to expect from spaceflight, but as the seconds ticked away to liftoff 40 years ago this day, we still had hope that this strange contraption wouldn’t disappoint.

At first, as the main engines ignited, it seemed that Columbia would indeed disappoint. The liquid hydrogen exhaust plume seemed anemic, at least compared to the gout of incandescent kerosene that had belched out from every rocket I’d ever seen launched. But then those magnificent — and as it later turned out, deadly dangerous — solid rocket boosters came to life, and Columbia fairly leaped off the launchpad. Americans were on their way to space again after a six-year absence, and I remember cheering astronauts John Young and Bob Crippen on as I watched the coverage with my dad that early Sunday morning.

Continue reading “Space Shuttle Program: 40th Anniversary Of The First Launch Of Columbia”

Queen Victoria’s Secret (Teletype And COSMAC Elf)

We don’t really think anyone in the Victorian era had a COSMAC Elf — the homebrew computer based around the RCA 1802 CPU. But if they did, it might have looked like [Daniel Ross’] steampunk recreation of the system that includes an appropriate-looking teletype device. You can see the thing in a series of videos, below. There are actually quite a few videos showing different parts of the system, along with several blog postings stretching back a few months.

A magic eye tube doesn’t look out of place in this build. We especially liked the glass tube displays and the speaker, although we thought the USS Enterprise looked out of place with the technology based on stone knives and bearskins, to paraphrase Mr. Spock. On the plus side, the VFD displays have the right glowing look, although a Nixie would have been pretty good there, too.

The videos don’t have much detail, but the blog posts do if you wanted to attempt something similar. Honestly, 1802 system design is pretty easy thanks to the its on-chip DMA that allows you to load memory from switches with no actual software like a monitor. The teletype started out life as a Remington #7 from around 1900, although another newer machine donated parts to get everything working. It is a testament to how well things were built then that it took as much abuse as it did and still has working parts.

We have a soft spot for the 1802 — it was a very good design for its time. We’ve even gone as far as to simulate it.

Continue reading “Queen Victoria’s Secret (Teletype And COSMAC Elf)”

Eyecam Is Watching You In Between Blinks

We will be the first to admit that it’s often hard to be productive while working from home, especially if no one’s ever really looking over your shoulder. Well, here is one creepy way to feel as though someone is keeping an eye on you, if that’s what gets you to straighten up and fly right. The Eyecam research project by [Marc Teyssier] et. al. is a realistic, motorized eyeball that includes a camera and hangs out on top of your computer monitor. It aims to spark conversation about the sensors that are all around us already in various cold and clinical forms. It’s an open source project with a paper and a repo and a how-to video in the works.

The eyebrow-raising design pulls no punches in the uncanny department: the eye behaves as you’d expect (if you could have expected this) — it blinks, looks around, and can even waggle its brow. The eyeball, brow, and eyelids are actuated by a total of six servos that are controlled by an Arduino Nano.

Inside the eyeball is a Raspberry Pi camera connected to a Raspi Zero for the web cam portion of this intriguing horror show. Keep an eye out after the break for the Eyecam infomercial.

Creepy or fascinating, it succeeds in making people think about the vast amount of sensors around us now, and what the future of them could look like. Would mimicking eye contact be an improvement over the standard black and gray oblong eye? Perhaps a pair of eyes would be less unsettling, we’re not really sure. But we are left to wonder what’s next, a microphone that looks like an ear? Probably. Will it have hair sprouting from it? Perhaps.

Yeah, it’s true; two eyes are more on the mesmerizing side, but still creepy, especially when they follow you around the room and can shoot frickin’ laser beams.

Continue reading “Eyecam Is Watching You In Between Blinks”

Zinc Fever: A Look At The Risks Of Working With Hot Metal

For as raucous as things can get in the comments section of Hackaday articles, we really love the give and take that happens there. Our readers have an astonishing breadth of backgrounds and experiences, and the fact that everyone so readily shares those experiences and the strongly held opinions that they engender is what makes this community so strong and so useful.

But with so many opinions and experiences being shared, it’s sometimes hard to cut through to the essential truth of an issue. This is particularly true where health and safety are at issue, a topic where it’s easy to get bogged down by an accumulation of anecdotes that mask the underlying biology. Case in point: I recently covered a shop-built tool cabinet build and made an off-hand remark about the inadvisability of welding zinc-plated drawer slides, having heard about the dangers of inhaling zinc fumes once upon a time. That led to a discussion in the comments section on both sides of the issue that left the risks of zinc-fume inhalation somewhat unclear.

To correct this, I decided to take a close look at the risks involved with welding and working zinc. As a welding wannabe, I’m keenly interested in anything that helps me not die in the shop, and as a biology geek, I’m also fascinated by the molecular mechanisms of diseases. I’ll explore both of these topics as we look at the dreaded  “zinc fever” and how to avoid it.

Continue reading “Zinc Fever: A Look At The Risks Of Working With Hot Metal”