#matching one transform3d's rotation to another while constrained to a maximum angular speed

1 messages · Page 1 of 1 (latest)

maiden mirage
#

i have two transform3ds, they are identical except for rotation. i want to rotate the first one to match the second one while not rotating faster than some arbitrary scalar value.

so for example if A is rotated to (0,1,0) and B is (1,0,0) and the scalar is 0.1 then A should rotate towards B by 0.1 radians over one second.

how can i do this?

#

alternatively i'm also open to a different way of doing this that doesn't involve transform3ds. i'm using them because the rotation function i've implemented modifies the transform with quaternions and then returns a new transform

#

but to be honest i have no intuition for math more complex than basic vector operations

manic void
# maiden mirage i have two transform3ds, they are identical except for rotation. i want to rotat...

I think something like this would work:```php

if your forward direction is something other than z, change it

angular difference between the two basi (this doesn't take into

account rotation around the forward axis)

var angle_difference := acos(t0.basis.z.dot(t1.basis.z))
var tween := create_tween()
tween.tween_method(
func(weight: float): transform.basis = t0.slerp(t1, weight),
0.0,
1.0,
angle_difference / radians_per_second,
).set_ease(Tween.EASE_IN_OUT)

#

If it looks wrong, you probably have to tweak the angle difference calculation to take into account roll as well

maiden mirage
#

i'd like to find a way to do this without slerp cos i never know if linear interpolation functions are framerate independent but this works for now

manic void
# maiden mirage i'd like to find a way to do this without slerp cos i never know if linear inter...

If you've got the time, I highly recommend this talk by Freya Holmer about this very topic https://youtube.com/watch?v=LSNQuFEDOyQ

a journey through decay and delta time (I had to learn differential equations for this oh boy)

Slides: https://www.patreon.com/posts/105228270 for my patreon supporters 💞
The slides are much nicer in person!! like, the AV team on site had me lower the refresh rate on my laptop because we couldn't get it to work otherwise, and on top of that, vi...

▶ Play video
maiden mirage
manic void