Adasha
24th June 2004 22:52 UTC
help with camera rotation
Hey all, a request for help if I may
I've got a camera following an arbitrary path around a SSC object, which is centered on the origin. I'd like to have the camera orientate itself towards the scope's centre.
I can do it easily enough in 2d with atan2 and I assumed I'd just need to extend that into 3d, maybe with a bit of Pythagoras, but I'm not making any headway
<edit> Does it matter which order I'm rotating the axes? It's x,y,z right now </edit>
Tell me straight... am I missing the obvious?
mikm
24th June 2004 23:25 UTC
3D SuperScope (incl. rotation) link
Adasha
25th June 2004 00:09 UTC
thanks m2k but the 3d part I'm more or less comfortable with. I was looking more for a way to make the camera point to the origin (i.e. calculate rx, ry and maybe rz, based on the camera coordinates), as it will be following various paths blended together randomly and I always want the scope in view
might not help, but here's the preset. feel free to point out any other corrections ;)
dirkdeftly
25th June 2004 09:54 UTC
there's a method for that that's pretty simple once you know its derivation. unconed uses it in his energy ball preset and other similar endeavours of his, if you want to take a look at that code. it's kind of dodgy code if you don't know raytracing in avs, but that's the best advice i can give you for the moment...i'm far to tired to be trying to derive those formulas right now ;)
good luck
jheriko
26th June 2004 17:38 UTC
ry=atan2(-ox,-oz);
rx=atan2(oy,sqrt(sqr(oz)+sqr(ox)));
rz=0;
this is for zxy rotated superscopes for zyx just swap appropriate vars.
it comes from pythagoras theorem and some trig, draw a 3d diagram to see how it works.
UnConeD
27th June 2004 19:42 UTC
This formula depends on the order of your rotations. The most natural is z,x,y (or reverse for camerabased scopes).
Adasha
28th June 2004 01:09 UTC
took a little experimenting, but got it!
appreciate the help, thanks!