Today I Learned:
1) In C, if you’re using an external variable and you malloc it (which, I suppose, you have to do sometime), be careful how you do it. If you declare its type when you malloc it, it will be allocated as a local variable unconnected to the external variable. If you want to actually use it as an extern, you have to declare it *without* its type. So
extern int* x;
x = malloc(2048);
will give you the *actual external variable x*, while
extern int* x;
int* x = malloc(2048);
will give you a *local* variable named x that isn’t related. Intuitive, right? …
2) …why acrylamide is toxic. Acrylamide is a small molecule used a lot in molecular biology to make gels, which you can run proteins or DNA (usually proteins) through to separate them out by size or charge or other things. Acrylamide gels are perfectly harmless, and can, for instance, be thrown out safely in regular garbage. Unpolymerized acrylamide powder, on the other hand, is a neurotoxin and has to be handled pretty carefully.
Today I learned *why* acrylamide powder is toxic. It turns out it’s because acrylamide in the bloodstream can very easily enter the brain… and polymerize there. Well how about that.
3) The Chaos Game Representation (CGR) I talked about a few TILs ago can be used to draw Sierpinski triangles and other fractals. Here’s the algorithm for a Sierpinski triangle:
* Start with a triangle
* Draw a point at the center
* Randomly pick a corner and draw a point halfway between that corner and the last point you drew. Repeat this step a bunch.
From a little experimentation of mine (and ideas from Robert Johnson), I’ve found that you can probably get a Sierpinski-looking fractal from any similar algorithm with more “dimensions” than degrees of freedom — for instance, you can do the same thing by drawing inside a pentagon but only picking from four points.
EDIT: Whoops, looks like it might not have to have more dimensions than degrees of freedom — it still makes a fractal if you use all of the points of a pentagon.
No comments:
Post a Comment