Pages

Tuesday 31 August 2010

Ray Tracing Library AS3

About a year ago I wrote a ray tracer. I've decided to the same thing again, building from the ground up, and taking a completely OOP approach - which I didn't do before. I was very pleased with previous results, but given the lack of structure implementing certain features became a real headache, and a lot of code had to be rewritten each time I wanted to make a small change.

At the same time I will try to speed up the engine, try to stick to bitwise operators and vectors whenever possible. With any luck it'll be up and running in the next few weeks, but I will keep you updated along the way.

Here are some screenshots from the previous ray tracer:




Monday 9 August 2010

FlashMath Demo 1

Just a really simple demo, which uses the FlashMath library. Click to launch it. The demo uses a string evaluation function to generate the curve. This function is also used to calculate the integral of the curve using Simpsons rule between min and max, and by clicking on the graph, finite differencing is used to calculate the gradient of the curve. Data set and graph classes are used to store / draw the data. The parser was created by http://www.undefined.ch/ and is a really useful tool! The demo might be a bit buggy at the moment, but its a good sign of things to come!

Tuesday 3 August 2010

Experimentalized Maths Library

It struck me today, that although I reuse a lot of code and classes, the one thing I tend to rewrite each and every time I start a new program is the mathematics. I dread to think how many hours this has wasted me over the years, so I finally decided to write a toolkit encompassing almost anything maths based. So far I've written a couple of constant utilities, one for mathematical constants, and one for scientific constants and a complex number class. Currently on the list are:
  • Matrices
  • Data sampling and statistics
  • Quadrature (integration) - Rectangle, Trapezium & Simpson's rule 
  • Numerical differentiation - finite differencing ✔,  runge-kutta (and other ODE solvers)
  • Graphs
  • Vectors ( 2, 3  and N dimensional)
  • Geometry class & trigonometry solvers
  • Probability
  • Random numbers (Mersenne Twister, other PRNGs)
  • Time and date
  • Complex numbers 
  • Bitwise operators 
  • Mathematical constants 
  • Scientific constants 
It would be great if you could let me know what kinds of maths utilities you would find useful, and even better if you have some of your own code and would like to collaborate with me on this.

Update: Your suggestions:

  • Bezier curves (Cubic & Quadratic), Bezier surfaces?

FLAR Toolkit - First Go

I thought I'd finally get round to having a go with the FLAR toolkit (an augmented reality toolkit for flash). I made a marker which will be used in any AR experiments I do on the site, then quickly made a test program. All I can say is it works quite nicely and I'll be playing around with it in the near future. Click the second image to run the test!

Sunday 1 August 2010

Webcam Gestures in Flash

I'm currently creating a game which involves gesturing as the primary control method. For those who aren't familiar with the term gesturing, it was created to describe a set of motions carried out on a touch screen. I thought it would be pretty cool to make the keyboard and mouse completely obsolete and applied my gesturing algorithm to the webcam. Getting timings right with the webcam was the hardest part. You can choose when to start and stop using a mouse, but how do you tell when one gesture ends and the next begins on the webcam.

Click below to watch a video of the experiment in action:


It works by calculating the angles travelled in a gesture. It compares these to a list of angles which relates to a certain gesture. For example for a straight line in the positive horizontal direction this would be 0-0-0-0-0 or in the negative horizontal 180-180-180-180. The program determines which preset gesture the carried out gesture is most like and then performs an action based on this choice. The result is by no means stable, but using a better set of thresholds and presets can improve the performance dramatically.

Click here to launch the experiment and have a go yourself. Remember you'll need a webcam to do so.