It is quite simple question. How to transform rotations from local to absolute? If I breakout a rotator it becomes limited by 180 and -180 … however, i would like to have that rotation absolute… is there a workaround for it? I’m asking this because i have a second order dynamics solver which can not solve for rotations this way.
If you want absolute, then you need to use quaternions. Otherwise the engine will constantly be fiddling with your results.
Only two ways to avoid the problem I know are:
-
Use ‘combine rotators’ ( watch the ordering )
-
Only ever add local rotation ( do not compute absolute values )
I tried to obtain the absolute value with quaternion transform but wasn’t able in the blueprints. Is there a way to find them other than C++ scripting?
There are some basic blueprint ( quat ) nodes. And you can convert back and forth ( just by connecting pins ), but I think it you really want to get stuck in, you either have to get a plugin or write your own nodes ( in C++ ).
Strangely, the plugins I was looking for no longer exist ( presumably due to lack of interest ), but there is this ( very expensive ) thing
which is only blueprint. Maybe there is some dark magic possible…
( I also see a couple of things on github ).
PS: To be clear, if you want to perform rotation calculations without worrying about results flipping over, I think you can do the computations with rotators, as long as you use ‘combine’ and ‘delta’.
I found a ready-made bp that was posted somewhere for rotator to quaternion conversion. However, I’m not sure if that’s the right way of doing it even though I don’t know how to access that angle from the quat functions yet.
Is it safe when using ‘combine’ and ‘delta’ ?
Like I say, I think you can do this
And yes, so far combine and delta seem to do the trick. I suspect the Quats are being used in the code.
Oh alright that should do the rot to quat transform. Any tips on how to use ‘combine’ and ‘delta’ in this case? sorry I’m not that good at math
Tell me what you want to do…
Simply transform an angle from the rotator into absolute form by using your suggestion which involves the use of ‘combine’ and ‘delta’ functions
What do you mean by ‘absolute form’? Do you want to rotate something?
The best you can get is the object not jumping. You can’t get 720 degrees or something like that…
I don’t think that’s what the OP is looking for…
Tbh not really sure what he is after, most blueprint nodes should already be using quaternion calculations under the hood.
That’s what I thought. But there is this problem with the system change 180 to -180 when it feels like it
I also think we have a terminology issue here…
Ah he just wants it as an absolute value clamped between 0 and 360?
0 → 180 is just half a round clockwise, 0 → -180 is the same thing counterclockwise.
Dumb logic would suggest checking if value is negative, and if it is, 360 - abs(rotationvalue), else just take the rotation value as is.
Oh in absolute form I meant by, if an object is rotated more than 180 It should keep on rotating in absolute form instead of limiting the rotation to -180 and 180. The thing I’m trying to do is I’m trying to get rotation of an object and pass it by a second order solver. The solver instead needs linear input without limits otherwise it will not solve correctly.
I made a video about it just so you understand what I’m facing. sorry if I could not describe my problem any better. And no Josf it’s not a clamped value that I’m trying to use.
The only way I’m thinking about it is making a function that counts each one complete rotation made and adds 360 upon each turn, however I don’t think it’s safe to do it that way because it probably depends on the tickrate.
The reason why rotations under the hood are calculated in quaternions is to avoid gimbal lock in the case of euler angles and to avoid having to operate on much more data than necessary in compared to forward/up/right vectors. The rotations do not really have “rounds”, they are done using SLerp which needs quaternions.
You can try storing some absolute rotation value to which you add the delta on each tick, I guess. Hard to really know what you need it for though.
Looking at your vid, I would say as long as the gun is mounted on the socket, the rest can be done just with the player control rotation. No?
actually I have never thought about storing it that way… I’ll give it a try. Although it will work but incase if there is lag/stuttering from alt-tabing for example that may cause misrotation (at least I think so). However I’ll give it a try :)…