C++: Notes on moves and copies

I found the behavior of Objects in STL containers a bit confusing, so I wrote down some notes for myself. (I've updated this post after helpful comments from my colleagues Vladimir Semenyuk and Björn Pollex. They pointed out that I hadn't implemented copy and move constructors in my original code. Hopefully the post now looks …

Advertisements

মৌলিক: A prime number toy

Moulick (মৌলিক - Bengali for Prime) is an Arduino powered mathematical toy that endlessly computes primes and shows fun statistics about them as it goes along. Watching primes born was never more exciting, or slow. Moulik  starts from 2 and takes you primally all the way out to 10 decimal digits at a recklessly unsafe speed …

A modification to Bresenham’s algorithm

The whole of last week I found myself staying up late at night writing C++ code to draw animated data displays on a 2.8" LCD screen driven by an Arduino, entranced by the addictingly quick cycle of writing code and putting it on the micro-controller. The tiny size, razor sharp resolution and bright colors of …

Debouncing a touch screen

I was coding up an Arduino app that allows a user to tap and drag on a touch screen to move an object. Everything went great but then I discovered that I could not interpret a drag motion. Whenever I dragged along the touchscreen the system would report that I was actually tapping and letting …

volatile

I love the volatile variable qualifier. I never had to use it until I started playing with an Arduino and so it was double the fun. When you mark a variable volatile you are telling the compiler to make no assumptions about the variable during compilation. For example, in a loop like:   the compiler …

pow(*,1./7.)

I was reading through some code (this file from the REBOUND N-body simulator) when I came across this function: and I got very curious as to how it worked, and why one would need it and mostly about whether it would generalize to arbitrary values of base and exponent. We see that we have an …

Computing orbits (1)

I want to simulate the orbits of planets and moons in our solar-system. They will form a carousel of gravitational bodies that my little spaceships will lift-off from, orbit around, and slingshot past, on their imaginary journeys of adventure and derring-do. The wikipedia article on orbit modeling is a nice introduction to some of the concepts involved. …