Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and

Wednesday, 17 December 2008

Putting a new tilt on it

Right from the start I wanted my Saucer shape to be fully capable In order to do rotations I have translated the vertices's of my saucer from Cartesian coordinates to polar coordinates (you can use a spreadsheet to to this, what you need is the atan2 function which takes x and y values separately (this gives you the both positive and negative radian values (-π to +π, however processing uses 0 to 2π so you need to adjust your angles accordingly). To calculate the radius just use Pythagoras's theorem radius = √(x2 + y2)
To see my lovely tilting Saucers:
checkout my chunk 68 blog

Update 6 January, I recently came across a PVector class which I think is a relatively recent addition to the processing language? The PVector class can be used to store both 2D and 3D vectors, but also has some interesting functions. There's a static method that takes two vectors and returns the angle between them, you can also manipulate the PVectors in other interesting ways which should be useful in animation (probably worthy of inclusion in the book, I don't think Greenberg mentions it).
However decided my next move on the animation front would be tilt my saucer in the direction of travel according to its velocity in the x direction see refactored processing applet. The trick is to store the position of the previous saucer instance, the difference between that and current position gives you the velocity (for effect and convenience I only worry about velocity in the x dimension).

No comments:

Post a Comment


Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby- and processing-3.2.2