|
Post by Buzz Carols on Aug 9, 2011 23:49:52 GMT
I would like to rotate an object 6 degrees on the X axis and 45 degrees on the Z. I only see how to set one axis at a time. Is there a way to do both?
|
|
|
Post by Perishingflames on Aug 10, 2011 1:26:47 GMT
If you're on a pc, rotate the first axis using the rotation field, then alt-click and drag the other axis. Know that this will product buggy interiors (in that the marble can easily get stuck in them) though. A while back there was some discussion about the way the rotation field works here and here but nothing that's going to help. I thought I remembered technostick figuring it out but can't find the thread.
|
|
|
Post by Sporlo on Aug 10, 2011 18:51:48 GMT
He's on a Mac, so from what I've heard and from my own experience, manually rotating objects is impossible. (within the level editor)
Also, Riblet, if you enter .5 .5 0 90, the game WILL rotate the object by (close to) 45 degrees in both the X and Y direction. However, it will also reassign the numbers (√2)/2 (√2)/2 0 60. I have NO idea why. And if you multiply (√2)/2 by 60, you get 42 something.
|
|
|
Post by Sporlo on Aug 10, 2011 19:05:14 GMT
Yeah, that's what I had noticed. Someone should go through every single one of Technostick's posts and try to find the real explanation I'm looking atm actually. But the search function is being buggy right now. I asked it to look posts containing "rotation" made by technostick, but instead it's returning only posts made by technostick and ignoring the "rotation".
|
|
|
Post by Perishingflames on Aug 10, 2011 19:19:15 GMT
Use google, site:marbleblast.com to search this site. However, it will also reassign the numbers (√2)/2 (√2)/2 0 60. I have NO idea why. And if you multiply (√2)/2 by 60, you get 42 something. Like that person posted before, that looks just like sin(theta) cos(theta) 0 but likewise I have no idea what the 60 is for. And the 0.5 0 1 90 example doesn't hold up for 1 0 1 90 to rotate it 90 degrees on the x and z. I think that's just coincidence not the rule.
|
|
|
Post by Riblet on Aug 10, 2011 19:24:28 GMT
I've also noticed that if you type in a value like .25 .5 0 90 the interior becomes just as problematic as using the alt-rotate method (which I don't think works on mac?)
I would love to know the real explanation...
|
|
|
Post by Sporlo on Aug 10, 2011 19:26:39 GMT
Use google, site:marbleblast.com to search this site. Genius. (so simple I didn't think of it) Anyhow, I managed to find the old threads: www.garagegames.com/community/forums/viewthread/40000And this MBF thread I myself actually started with a question very similar to ajdallas. marbleblast.com/index.cgi?board=lbrb&action=display&thread=1715I've also noticed that if you type in a value like .25 .5 0 90 the interior becomes just as problematic as using the alt-rotate method (which I don't think works on mac?) I would love to know the real explanation... Correct: doesn't work on a Mac. Also, I too noticed that even typing in something like .5 .5 0 90 caused the interior to bug out. technostick starts talking about quarternions. So I randomly Googled it and here you go: (not that I think this will be helpful, but it's something to read if you get bored) en.wikipedia.org/wiki/Quaternions_and_spatial_rotation
|
|
|
Post by Riblet on Aug 10, 2011 19:44:54 GMT
So yeah, all these discoveries were already made 5 years ago. Doesn't look like anyone ever came up with a real clarification though...and glancing at that wikipedia article looks like I won't be one to help write it up
|
|
|
Post by Sporlo on Aug 10, 2011 19:47:31 GMT
|
|
|
Post by Buzz Carols on Aug 10, 2011 21:49:23 GMT
We looked at the GarageGames thread that Sporlo posted. It made things much clearer.
0.14 0 1 45 :
X = (0.14 x 45) = 6.3 deg Y = (0 x 45) = 0 Z = (1 x 45) = 45 deg
So, this is close enough, since we wanted X=6, Y=0, Z=45. Buzzmusic100 will try this out and post back the results.
Thanks so much for the help and links!
|
|
|
Post by Hi Guy on Aug 11, 2011 2:25:09 GMT
Um, unknown possible solution, but try this: Desired: 6 0 45So we add 6 + 45 = 51And we divide 6/51 = 2/17 = 0.11764705... 45/51 = 15/17 = 0.88235294...So we fill in: 0.11764705 0 0.88235294 51That is how I think it works, but I'm not certain. HiGuy EDIT: Just tried it, looks pretty much like 6 x 45 z. Can't be quite sure. Also, it changed the rotation values to this: 0.132164 0 0.991228 45.0671Hmm... EDIT EDIT: Fixed a few things. Also noticed you solved it Oh well. I wonder if this ( ^ ^ ^ ) is how it actually works...
|
|
|
Post by Seizure22 (Witty Title) on Aug 13, 2011 2:10:23 GMT
the problem here is that we all gravitate towards quaternions when it actually uses axis angles, a similar four-unit way to represent rotation
this is the code you want:
//Axis Angle to Euler (Pitch Yaw Roll); Credit: Matthew Jessick and Brendan Fletcher @ GG Community
function rotAAtoE(%axisAngle) { %angleOver2 = -getWord(%axisAngle,3)/2; %sinThetaOver2 = mSin(%angleOver2);
%q0 = mCos(%angleOver2); %q1 = getWord(%axisAngle,0) * %sinThetaOver2; %q2 = getWord(%axisAngle,1) * %sinThetaOver2; %q3 = getWord(%axisAngle,2) * %sinThetaOver2; %q4 = %q0*%q0;
return vectorScale(mAsin(2*(%q2*%q3 + %q0*%q1)) SPC mAtan(%q0*%q2 - %q1*%q3, (%q4+%q3*%q3)-0.5) SPC mAtan(%q0*%q3 - %q1*%q2, (%q4+%q2*%q2)-0.5) ,-180/$pi); }
//Credit: Eric Hartman @ GG Community (function originally called eulerToQuat)
function rotEtoAA(%euler, %rotflag) { %euler2 = VectorScale(%euler, $pi / 180); //convert euler rotations to radians %matrix = MatrixCreateFromEuler(%euler2); //make a rotation matrix %xvec = getWord(%matrix, 3); //get the parts of the matrix you need %yvec = getWord(%matrix, 4); %zvec = getWord(%matrix, 5); %ang = getWord(%matrix, 6); //this is in radians if (!%rotflag) %ang = %ang * (180 / $pi); //convert back to degrees %rotationMatrix = %xvec SPC %yvec SPC %zvec SPC %ang; //put it all together return %rotationMatrix; //send it back }
setting %rotflag to true will return the last unit in degrees.
generally, you should not use degrees other than
- when inputting a value in the editor - when creating a new game object from script - when editing a mission directly
all other uses (including setTransform, getTransform, and our RotAAtoE function above) will use radians for the last unit.
now, to [attempt to] solve OP's problem:
%object.setTransform(%object.getPosition() SPC rotEtoAA("6 0 45"));
this may not solve your problem if the game applies rotations to axes in a different order than you expect.
|
|
|
Post by Riblet on Aug 13, 2011 4:36:26 GMT
Whoa, that explains a lot. Thank you so much, Seizure. I have no idea what to do with your code there, but To answer OP's original question, I believe the numbers you would input into the rotation box would be .125 -.051 .99 45.37I hope I didn't mix around the numbers. I don't really know what I'm doing but here's a simple guide if you're like me and have no idea what to do with Seizure's stuff: Use the java calculator at www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToAngle/program/index.htminput the angles of rotation you want, make sure both settings are in degrees heading = z attitude = y bank = x you get some numbers at the bottom right, you'll want to put these into marbleblast in the order X Z Y Angle this at least works for me, there's probably a way that's heaps better than this but at least we understand what's going on now. If someone can make this easier please do
|
|
|
Post by Pablo on Aug 13, 2011 7:03:57 GMT
Glad this finally got solved. Thanks, Seizure! Stickied.
|
|