I finally made the tracker and the particle bit of my program into separate classes, thus making it much easier to handle, adjust and tune. Now I can concentrate on the details of some more specific details, like how to move the particle in a way that it does not drift off of the screen ... The problem of that lies in the fact that an angle is measured from 0 to 2 PI, or -PI to PI, which is in all practical matters the same. This is a problem because it is not linear, but circular(!) ... I.e. it means that at some point, an angle switches from being close to 0, to 2*PI! So, even though an angle only just changes slightly, its value changes drastically. This gives me a problem when it comes to comparing two angles, trying to adjust one angle to the other, especially in a 'fluid' way ... I still haven't found a solution to this, but I'm not giving up! :) If you look at the applet now (http://www.rsd.no/ExperimentalAnimation/) you will see that the particles slowly drifts away to the left. This is directly related to this problem. I'm not sure how to solve this yet, but I hope I will manage to in the near future.
Also, I hope that the applet will work in other people's browsers. There is this issue with trust ... Since I'm accessing other people's web-cams, it is treated as a potential security issue by Java (which is what Processing is based on) and therefor requires certificates. I managed to make it work in my own browser, but I'm not sure if it will work for all. Oh, by the way, this is an applet that uses video stream from your camera on the computer, so unless you have one, this applet won't do much good for you.
Edit: I did find a solution to it. I had to implement a counter/timer to the function that was comparing the two angles, so that at least one of the angles did not stay at the zero/TWO_PI point. It is a hack, and I still do not know of any better way to solve this. My solution works well for this applet, especially because it involves some randomness, but what if one requires 100% accuracy? To reiterate the problem: how do you compare two angles that might be very close to each other, and one of them is varying slightly, thus making its value shift from close to zero to close to 2*PI?
Tuesday, April 21, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment