Shock Value
5th June 2003 00:50 UTC
2D rotation problem
Quick question. Shouldn't ...
theta
=pi*cc/2;
d=sqrt(x2*x2+z2*z2);
r=atan2(x2,z2)+theta;
x2=d*sin(r);
z2=d*cos(r);
... and ...
theta
=pi*cc/2;
ct=cos(theta);
st=sin(theta);
x2=x2*ct-z2*st;
z2=-x2*st-z2*ct;
... do the exact same thing? I thought so, but the second one seems to be acting differently (in other words messing my whole scope up).
EDIT: Figured it out. I just needed to make new variables in place of x2 and z2 instead of using them over. Not sure why I would have to do this with the second method and not the first though.
Would a mod be kind enough to lock/delete this thread?
dirkdeftly
5th June 2003 04:03 UTC
...
x2=x2*ct-z2*st;
z2=-x2*st-z2*ct;
you're altering x2, a term used in the z2 statment, before you get to the z2 statement. to get it to work properly use different variable names, or a storage variable:
x3=x2*ct-z2*st;
z2=-x2*st-z2*ct;
or
x2a=x2; x2=x2*ct-z2*st;
z2=-x2a*st-z2*ct;
Shock Value
5th June 2003 23:36 UTC
Aha, thanks for pointing that out, Atero. And to anyone who cares, my second pack should be done soon.
dirkdeftly
6th June 2003 00:36 UTC
you do mean third pack, right? i could swear i've already got two on my comp...yep, i do....
sidd
6th June 2003 01:07 UTC
me too: onTV and Pixels..