Hey all, I’m discontinuing p5wscala. It was a fun time in my programming career but I have since moved onto other things, and I want an outlet to share my experiences – but this blog doesn’t serve that purpose, since this one is dedicated to that very specific category of programs written in Scala using the Processing library. Thanks to everyone who’s been reading, I hope they’ve been of some help.
I have a new blog at blog.zhangxiaohan.com; I have copied all the posts from this blog over there, and will definitely be picking blogging back up. The topics will be of a more general scope though – less of a specified goal; more just “what am I doing?”
Update: I have no immediate plans for continued blogging and have since disabled that older site. Keep up to date with me at http://www.hellochar.com/! Thanks!
This isn’t Scala related, but a couple days ago I submitted an entry into the bus-tops contest under the title vectorfield. I’m really pleased with the result. It’s interesting how limitations lead you to new places. The 8 framerate limit actually inspired me to put in way more dots than I originally intended, which then led to profiling + optimizing iterations.
The game is really making progress:
A while back, Hackers at Berkeley hosted a small session on Artifical Intelligence, introducing (among other things) the Markov Chain. I decided to implement my own for random word/name generation, using single letters as states and training on about 22k English words (wlist_match10 at http://www.keithv.com/software/wlist/). This gave me some decent results:
And some less decent results:
I also wanted to visualize these connections in a way that quickly portrayed information, so I took my old friend the Particle System and connected all the letters up according to how high the probabilities were.
It’s a bit messy, but you can see several interesting features of the English language. The most striking thing was that the most common vowels (a,e,o) always float towards the center of the system. You can shake up the mass but the sheer number of relatively balanced connections makes the vowels only stable near the center.
Hey, it’s been a bit since I’ve updated but I’m alive and well; been collaborating with Brendan on an upcoming game. Here’s a screenshot of an early prototype:
More to come!
This past week I took a job offer to do a quick applet for Fabripod. Fabripod wants to sell lamps, and they want to let people customize them to their liking – in particular, they wanted an online interface (aka an Applet) to let people control various parameters, and immediately see the resulting figure. Like this:
You basically partition the sphere into a set of quads (which are actually trapezoids), and then draw shapes projecting out from each normal. It’s much easier to act as if every quad has its own coordinate system and then transform the shape accordingly. It’s also quite amazing how fast one can develop with the right tools; this first sketch took less than a day to mock up.
Added a few more options and some indicators; by associating each indicator with a function that will calculate its value, it’s easy to simulate the displayed text as a def instead of a var.
This is basically the final version; it’s amazing what some good lights can do to a sketch. About halfway through this picture and the previous one I had to do a lot of code rewriting in order to cache; this involved changing most of my defs into vars and then doing “mutate on UI change” acrobatics. Pleasantly, the sketch runs at ~40 fps for almost all use cases (using software 3D rendering, since exporting an Applet using OPENGL is difficult).
My previous explorations really taught me that I had absolutely NO CLUE how to spherical geometry, so I’ve spent these past weeks teaching myself how to get around in spherical coordinates. I’ve come up with a potpourri of sketches exploring spherical geometry. These are mostly for my own benefit, but I thought I’d share anyways.
This sketch does the simplest things, like drawing great circles and small circles. It was a very good primer to start thinking in a spherical mindset. The strategy at this point was to always imagine important vectors being aligned along the XYZ axes, and which reduced the problem down to a much simpler one, and then implementing the solution through rotation transformations.
I wondered what kind of path a point on the sphere would take if it was constantly rotating around some moving axis. To this end, Rodrigues’ rotation formula proves extremely helpful.
Going back to my roots – gravitation! The red ball is gravitationally attracted to the green balls using a spherical distance metric. This was actually tricky because velocities aren’t as straightforward as they are in Euclidean space. I ended up creating the notion of a “Local Plane”, which is basically an azimuthal projection of the sphere centered at the red ball. This lets you do vector math as if you were in a simple 2D space, so it’s very easy to add forces and integrate for velocity.