Daily Archives: 11/2/2011

Making some wallpaper with the sum of cosines…

I was inspired by some Haskell code written by keegan, so I had to write a version of it in C. I didn’t do any animation, but I did have a lot of fun playing around with the parameters. For instance, check out the code, and how changing the value of N from 5, 7, and 19 generates interesting and cool patterns.

[sourcecode lang=”cpp”]

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>

/*
* quasi.c
*
* Some code, inspired by keegan @
* http://mainisusuallyafunction.blogspot.com/2011/10/quasicrystals-as-sums-of-waves-in-plane.html
* but presented without any further explanation.
*/

#define N (19)
#define XSIZE (1280)
#define YSIZE (720)
#define SCALE (0.2)

double x[N], y[N], ph[N] ;

double image[YSIZE][XSIZE] ;

int
main()
{
int i, j, k ;

for (i=0; i<N; i++) {
x[i] = cos(2.0 * M_PI * i / (double) N) ;
y[i] = sin(2.0 * M_PI * i / (double) N) ;
ph[i] = 0.0 ;
}

for (j=0; j<YSIZE; j++) {
for (i=0; i<XSIZE; i++) {
image[j][i] = 0. ;
for (k=0; k<N; k++) {
double d = (x[k] * (i – XSIZE / 2.) + y[k] * (j – YSIZE / 2.) + ph[k]) * SCALE ;
image[j][i] += (1.0 + cos(d)) / 2. ;
}
int t = (int) floor(image[j][i]) ;
assert(t >= 0.) ;
double v = image[j][i] – t ;
if (t % 2 == 1) v = 1. – v ;
image[j][i] = v ;
}
}

printf("P5\n%d %d\n%d\n", XSIZE, YSIZE, 255) ;
for (j=0; j<YSIZE; j++)
for (i=0; i<XSIZE; i++)
putchar(255. * image[j][i]) ;

return 0 ;
}
[/sourcecode]

Cool stuff!

BeagleBone, a new ARM-powered embedded platform

I really like the Arduino, but even I must admit that performance-wise, it can be a little, well, disappointing. A 16Mhz 8 bit processor can do a lot, but there is also a lot of applications where having something a bit beefier makes a lot of sense. Something with support for a richer peripheral set, like USB, Ethernet, and video.

Thus, it is with some interest that I learned of the Beagle Bone:



The Beagle Bone

I haven’t got one, but there are a couple of features which I think make it attractive:

  • The price is $89. Yes, it’s more than an Arduino, but it’s not a lot more than an Arduino Mega, and it’s not any more than an Arduino Mega and an Ethernet shield.
  • Web based development environment. This is kind of a mixed bag, but one of the advantages of the Arduino environment is that it’s a one stop shopping trip to get setup: there isn’t a need to install a lot of different tools to get going. For hobbyists, letting people get right to work is a big plus.
  • Enough power to run OpenCV and the like. The Arduino is simply too underpowered to even think of doing anything like that, so the Bone represents a big increase in functionality.
    It runs Linux. Yes, it’s kind of fun to run on relatively naked hardware, but sometimes it’s more expedient to have some support for multitasking.

A couple of nits to pick though: I thought it should have included some kind of video interface on the base board. The $89 price point begins to look less and less attractive if you have to get a $20-$30 daughter board to provide the video interface.

I also think that it’s just a bit more expensive than I would like. If you compare it to the feature set of another microcontroller in the works, the Raspberry Pi, with a price of $35 dollars (for the Model B) with ethernet and video, but without the same level of expandability, the Raspberry Pi might be a good choice for education and hobbyist level hacking at a lower price (indeed, a price equal to an Arduino Uno).

To be fair, you can buy an Arduino Uno today, whereas the Beagle Bone and the Raspberry Pi are both still in the works.

It’s a great time for the hobby computer hacker though.