Calculate rotation rate in rads?

I have a spinning platform, I want to calculate how quickly it is spinning in the Yaw Axis in rads. How do I do this. I have looked it up in the devoforum and not many relevant results I could see. Google gave me scholarly articles with 100 page pdfs. Please help


this?

First of all you should know part angular velocity, since you you are in control of whatever is causing the platform to spin. For example using AngularVelocity, you are the one to set the speed.

That being said, determining the spin speed is not an easy task. There are 2 possibilities.

Easy:
Platform is not rotated (other than spinning)
If you are lucky and Your platform except for spinning is not otherwise rotated in other axes, you may simply use part orientation Y component to determine speed. Just remember that orientation is in degrees and not in radians! Make sure that platform cannot do more than half turn between polls. Do not poll to frequently either, as measurement will be inaccurate.

local last = platform.Orientation.Y
local interval = task.wait(.1)
local current = platform.Orientation.Y
print("Angular Velocity is: " .. math.rad(last-current)/interval)

Hard:
Platform is rotated in other directions, as well as spinning on Y axis.
This is hard because of how CFrames work. You will need to do some math with this one. I would save LookVector for both measurements and use trigonometry to determine the angle.
look vectors are always the same length. By calculating magnitude between them, you get something called an Isosceles Triangle. I Found this pic on the net to help you visualize:


Both “a” sides are your look vectors, and “b” is your magnitude. We know that a = 1. What you need is “ha” height of the triangle. If you can calculate that, then you can find your turn angle by using inverse sine function (arc sine):

local last = platform.CFrame.LookVector
local interval = task.wait(.1)
local current = platform.CFrame.LookVector
local mag = (last - current).Magnitude
local height = (math.sqrt(1 - (0.5*mag)^2) * mag) / 1
local speed = math.asin(height/1) / interval

p.s. I left redundant ones for clarity. Again make sure that platform does not make more than half turn between measurements.

1 Like

It turns out I never needed to do that but thank you.