A Math Based Personality For Games

We make no apologies for being hardware focused here at Hackaday, but that doesn’t mean we aren’t occasionally impressed by a particularly inspired feat of bit wrangling. For example, [t3ssel8r] has taken a break from his game to discuss his procedural animation system and the beautiful math behind it.

Sometimes, rather than having specific keyframes, games will instead use procedural animation. This means that the position is determined on the fly rather than a predetermined set of positions. Developers can use the combination of IK or FK (inverse or forward kinematics) to solve for rotation and positions of the joints that will place the end at a specific position. Particularly with crawling multi-limb things, it’s pretty easy to put a limb on the ground and keep it there until it’s too far away, pick a new spot, and move it there. It’s simple code to write and looks convincing. It can handle complex terrain and situations with different limb positions.

However, it doesn’t offer the chance to inject some life or personality into the movement as keyframes do. [t3ssel8r] goes through the equations and reasoning behind his semi-implicit Euler solver-based system. There are some fantastic explanations in the video, but the short version is that he has three parameters to control the system’s frequency, dampening, and initial response. This allows him to tweak the behavior in a somewhat intuitive manner. One problem is stability; if the timesteps get too large, the position quickly explodes outwards. Using eigenvalues (who ever thought you’d use those) to determine the minimum timestep allows the system to remain stable and take multiple smaller steps when needed or just bound the change temporarily.

If you’re looking for more animation, this blender plugin renders your PCB traces in a new light.

Continue reading “A Math Based Personality For Games”

Thermal printer with a loop of thermochromic foil inserted in it, printing digits of Pi on the loop.The digits gradually disappear from the foil as it exits the printer.

Celebrating The Infinity Of Pi Day With Thermochromic Foil

It might take you some time to understand what’s happening in the video that Hackaday alum [Moritz Sivers] shared with us. This is [Moritz]’s contribution for this year’s Pi Day – a machine that shows digits of Pi in a (technically, not quite) infinite loop, and shows us a neat trick we wouldn’t have thought of.

The two main elements of this machine are a looped piece of thermochromic foil and a thermal printer. As digits are marked on the foil by the printer’s heating element, they’re visible for a few seconds until the foil disappears from the view, only to be eventually looped back and thermally embossed anew. The “Pi digits calculation” part is offloaded to Google’s pi.delivery service, a π-as-a-Service endpoint that will stream up to 50 trillion first digits of Pi in case you ever need them – an ESP8266 dutifully fetches the digits and sends them off to the thermal printer.

This machine could print the digits until something breaks or the trillions of digits available run out, and is an appropriate tribute to the infinite nature of Pi, a number we all have no choice but to fundamentally respect. A few days ago, we’ve shown a similar Pi Day tribute, albeit a more self-sufficient one – an Arduino calculating and printing digits of Pi on a character display! We could’ve been celebrating this day for millennia, if Archimedes could just count a little better.

Continue reading “Celebrating The Infinity Of Pi Day With Thermochromic Foil”

Simple Arduino Build Lets You Keep An Eye On Pi

Are you a math aficionado in need of a new desk toy? Then do we have the project for you. With nothing more than an Arduino and a seven-segment LED module, [Cristiano Monteiro] has put together a little gadget that will slowly work its way through the digits of Pi forever…or until you get bored of looking at it and decide to use the parts for something else.

On the hardware side, we really can’t overstate how simple this project is. A common four-digit LED display is connected up to an Arduino Nano, which is then plugged into the computer for power. [Cristiano] is using a breadboard here, but you could just as easily use four female-to-female jumpers to connect the two devices together. We suppose this would be a pretty good project for anyone who’s looking to get some practical experience with PCB design as well.

The real magic is in the software, which [Cristiano] has been kind enough to release under the MIT license. Calculating Pi on such a resource-constrained chip as the ATmega328P is far from ideal, but by porting over a C++ algorithm developed by [Xavier Gourdon] and [Pascal Sebah] for their paper Computation of the n-th Decimal Digit of π with Low Memory he was able to pull it off, albeit slowly.

Now if you’ve got slightly better hardware, say a pair of Xeon processors and 96 GB of RAM, you could calculate Pi out to a few trillion digits for fun, but it wouldn’t look as cool as this little guy blinking away.

Continue reading “Simple Arduino Build Lets You Keep An Eye On Pi”

Tensors Explained

You can do a lot of electronics without ever touching a tensor, but there are some situations in which tensors are absolutely essential. The problem is that most math texts give you a very dry description that is difficult to internalize. That’s where [The Science Asylum] comes in. Their recent video (see below) starts with the dry definition and then shows you what it means and why.

According to the video, the textbook definition is:

A rank-n tensor in m-dimensions is a mathematical object that has n indices and mn components and obeys certain transformational rules.

That sounds a lot like an array but we are not sure what “certain transformational rules” really means to anyone.

Wikipedia does a little better:

[A]n algebraic object that describes a linear mapping from one set of algebraic objects to another.

These constructs are key to anything electromagnetic (including antennas) and show up a lot in stress calculations and quantum mechanics. Even Einstien’s theory of relativity uses tensors.

Continue reading “Tensors Explained”

Wolfram Engine Now Free… Sort Of

You’ve probably used Wolfram Alpha and maybe even used the company’s desktop software for high-powered math such as Mathematica. One of the interesting things about all of Wolfram’s mathematics software is that it shares a common core engine — the Wolfram Engine. As of this month, the company is allowing free use of the engine in software projects. The catch? It is only for preproduction use. If you are going into production you need a license, although a free open source project can apply for a free license. Naturally, Wolfram gets to decide what is production, although the actual license is pretty clear that non-commercial projects for personal use and approved open source projects can continue to use the free license. In addition, work you do for a school or large company may already be covered by a site license.

Given how comprehensive the engine is, this is reasonably generous. The engine even has access to the Wolfram Knowledgebase (with a free Basic subscription). If you don’t want to be connected, though, you don’t have to be. You just won’t be able to get live data. If you want to play with the engine, you can use the Wolfram Cloud Sandbox in which you can try some samples.

Continue reading “Wolfram Engine Now Free… Sort Of”

Creating Black Holes: Division By Zero In Practice

Dividing by zero — the fundamental no-can-do of arithmetic. It is somewhat surrounded by mystery, and is a constant source for internet humor, whether it involves exploding microcontrollers, the collapse of the universe, or crashing your own world by having Siri tell you that you have no friends.

It’s also one of the few things gcc will warn you about by default, which caused a rather vivid discussion with interesting insights when I recently wrote about compiler warnings. And if you’re running a modern operating system, it might even send you a signal that something’s gone wrong and let you handle it in your code. Dividing by zero is more than theoretical, and serves as a great introduction to signals, so let’s have a closer look at it.

Chances are, the first time you heard about division itself back in elementary school, it was taught that dividing by zero is strictly forbidden — and obviously you didn’t want your teacher call the cops on you, so you obeyed and refrained from it. But as with many other things in life, the older you get, the less restrictive they become, and dividing by zero eventually turned from forbidden into simply being impossible and yielding an undefined result.

And indeed, if a = b/0, it would mean in reverse that a×0 = b. If b itself was zero, the equation would be true for every single number there is, making it impossible to define a concrete value for a. And if b was any other value, no single value multiplied by zero could result in anything non-zero. Once we move into the realms of calculus, we will learn that infinity appears to be the answer, but that’s in the end just replacing one abstract, mind-boggling concept with another one. And it won’t answer one question: how does all this play out in a processor? Continue reading “Creating Black Holes: Division By Zero In Practice”

Wolfram Alpha Electronic Tips

Electronics takes a lot of math. Once you’ve mastered all the algebra and calculus, though, it is sometimes a drag to go through the motions. It also can be error-prone. But these days, you have Wolfram Alpha which will do all the work for you and very easily. I use it all the time when I’m too lazy to solve an equation or do an integral by hand. But did you know it actually has some features specifically for electronics?

If you want to do a lot with electronics — or nearly any technical field — you are going to have to learn some math and you shouldn’t just rely on tools like Wolfram to skirt understanding the math. Unfortunately, schools often teach us that the point to math is to get a correct answer. For bookkeepers and at the very final stage of engineering, that may be true. But the real value to math for engineers and scientists is to develop intuition about things. If you increase a capacitor’s value does that make its reactance go up or down? Does a little change in load resistance make a corresponding small change in power consumption or is it a lot more? So you should understand why math works. But once you do, using a tool like Wolfram can free you to focus on the abstract questions instead of the detailed “grunt work.”


Tip #1: Split Personality

Wolfram can’t seem to decide if it is a symbolic math program or a search engine. Sometimes just putting a topic name in can lead to some interesting calculations. For example, look what happens when you enter the word opamp: Continue reading “Wolfram Alpha Electronic Tips”