Blockland Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2018, 07:24:57 PM

Home Help Login Register
+  Blockland Forum
|-+  Blockland Forums
| |-+  Modification Help
| | |-+  How do I rotate an axis-angle around a normal vector?
Pages: 1 [2]
Author Topic: How do I rotate an axis-angle around a normal vector?  (Read 722 times)

« May 16, 2018, 04:12:08 PM »

Tried it right after I posted but no dice unfortunately. Are we sure axis-angles and quaternions are the same thing lol? I always thought axis-angles were the relatively simple concept that you explained but quats were terrifying theoretical 4d math cones or something
my understanding is that quats were axis angles but with then angle in radians, but given irrel's last post thats clearly not the case.
Ad Bot

Full members do not see ads

Punished Rally

« May 17, 2018, 03:40:57 PM »

Forgot to respond: Unfortunately the updated function didn't work either.

« May 17, 2018, 05:34:53 PM »

can you provide some details as to what's going wrong? or let me join your server? i'm likely misinterpreting something, and oversimplifying
Punished Rally

« May 17, 2018, 05:44:11 PM »

It's pretty difficult to explain, I tried doing it on a bunch of different surfaces but I couldn't find any patterns.

Essentially the static shape is created via a function that is fed a position and a brick normal
%rotation = normal2Rotation(%normal);

%explosive = new StaticShape()
datablock = C4PlacedStaticShape;
position = %position;
rotation = %rotation;
normal = %normal;
sourceObject = %source;
client = %source.client;

The initial axis-angle rotation of the shape is supplied by the first line there. Note that if you were to call %explosive.setTransform(%explosive.getPosition() SPC %rotation), I'm pretty sure the result would be inaccurate, because I believe one is supposed to be in radians while the other is in degrees?

Anyways at this point I'd get the transform and attempt to rotate it again like this:

%rotation = getWords(%explosive.getTransform(), 3, 6);
%rot1 = %rotation;
%rot2 = %normal SPC mDegToRad(90);
%rotation = combineAxisAngleRotations(%rot1, %rot2);
%explosive.setTransform(%explosive.getPosition() SPC %rotation);

I tried calling it with arguments in both orders to no avail, and I also tried adjusting the rotation before the shape is instantiated, as well as with and without mDegToRad(). The second rotation is created using the normal of the brick the shape is sitting on, and then just an arbitrary rotation of 90 degrees for testing purposes.

« May 17, 2018, 07:02:10 PM »

I keep reading lots of different things about quaternions and axis-angle representations, and they are definitely different. There appears to be multiple ways to convert between the two, so I'll keep reading and try to find the best one.
Do the rotations result in the shape still being normal to the face, or no?

EDIT: I feel a little stupid now. Just realized I should be doing vector addition. Replace
%quatCombined = %quatAngle1 * %quatAngle2 - vectorDot(%quatVector1, %quatVector2) SPC vectorScale(%quatVector2, %quatAngle1) + vectorScale(%quatVector1, %quatAngle2) + vectorCross(%quatVector1, %quatVector2);
%quatCombined = %quatAngle1 * %quatAngle2 - vectorDot(%quatVector1, %quatVector2) SPC vectorAdd(vectorAdd(vectorScale(%quatVector2, %quatAngle1), vectorScale(%quatVector1, %quatAngle2)), vectorCross(%quatVector1, %quatVector2));
« Last Edit: May 17, 2018, 07:10:47 PM by irrel » Logged

« May 19, 2018, 10:04:42 AM »

You should just be able to use MatrixMultiply("0 0 0 a1 a2 a3 a4", "0 0 0 b1 b2 b3 b4") to get a transform (translation, rotation axis, rotation angle) that applies both a and b
Punished Rally

« May 19, 2018, 10:37:33 AM »

Both of these solutions worked perfectly, thank y'all very much.

« May 19, 2018, 02:34:19 PM »

Glad I was able to help even with my odd solution!
Pages: 1 [2]  

Login with username, password and session length

Powered by SMF 1.1.20 | SMF © 2013, Simple Machines
Page created in 0.034 seconds with 19 queries.