banner ad
Thursday, January 04, 2007
3D xyz rotation v1

This is not rocket physics, working off the 3D sphere rotation post, the final  equation needed to rotate multiple clips in 3D space along the x y and z axis is found bellow.  This comes form translating the a clips x,y,z  properties into spherical coordinates. The result is a spherical rotation where elements closer to you will rotate and will keep their respective values along the x,y or z axis. 

		//--> rotate around y-axis				 		
var tempX = (this.x * Math.cos(rY)) - (this.z * Math.sin(rY));
var tempZ = (this.x * Math.sin(rY)) + (this.z * Math.cos(rY));

//--> rotate around x-axis
this.dz = (tempZ * Math.cos(rX)) - (this.y * Math.sin(rX));
var tempY = (tempZ * Math.sin(rX)) + (this.y * Math.cos(rX));

//--> rotate around z-axis
this.dx = (tempX * Math.cos(rZ)) + (tempY * Math.sin(rZ));
this.dy = (tempY * Math.cos(rZ)) - (tempX * Math.sin(rZ));

Use the sliders for X | Y | Z rotation.


»comments

Ali N said...

This is nothing new. Cause the code is published in Keith Peters Book "Foundation Actionscript - Making Things Move" on friendsofed.com.

Moreover, this version needs more CPU resources cause every clip is computing its own position and scale instead of a simple loop within a global onEnterFrame.

Best regards
Ali


Paul+Ortchanian said...

Hi Ali,

Nothing on this site is new. Its all centuries old mathematics equations applied to actionscript. Keith does it, Andre Michelle and Mario Killgeman doe it and so do many others.

The fact that I researchit, post it, comment it and build experiments from it is my way of contributing to the flash community. That in itself should be respected. By all means you can post your negative comments elsewhere.

cheers,


P.J. Onori said...

How dare you post things you feel like posting on your own blog! I mean, honestly, what were you thinking? ;)

Never mind Ali, I think it's safe to say many folks enjoy viewing these experiments.

P.S. - I promise not to tell anyone you didn't invent 3D.


andrea said...

well said Paul!
and thank you for the nice code once again!


Ali N. said...

Hi,
sorry, didn't want tell any negatives about that experiment. So i just enjoy it, too and do respect all this work on this site. Also, i just visit it daily and i didn't want to scorch sb. Just criticize it in a positve way. so everybody chill down...just a slight disagreement.


adam.neil said...

Hi Paul,

Great experiment. Do you think it would be possible to track the users mouse position and use those values to effect the rotation of the movie clips. It'd be great ito see a developed experiment with this added interactivity.

Thanks again Paul,
Your a legend!


Paul+Ortchanian said...

Hi Adam,

YOu could and the next experiments will have that functionality included. Cheers


Gabriel Mariani said...

I'm trying to port this to AS3, and i have mostly got it working. The only difference is that using your formulas, all the particles hone in onto one point in space. And the axis point isn't centered. I have tried using Keith Peters formulas with greater success, but it behaves differently than yours. the angle is a axis speed variable, rather than just setting the angle of the space like with yours. i was wondering if you could give some insight on what the difference could be. =/


Natasha said...

thank you for the nice code
I have found two interesting sources ( http://filesfinds.com & http://fileshunt.com ) and would like to give the benefit of my experience to you.


over air force ones said...

very helpfull!! thanks


Saren Lidan said...

Good answer, I am looking for the solution of the same question. Find the movies or mp3 you are looking for at megaupload-download.com the most comprehensive source for free-to-try files downloads on the Web


Name
URL
Email
*email address is not published
Remember Me
Comments

CAPTCHA






banner ad