Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

The math for BodyGyro's MaxTorque?

Asked by 3 years ago
Edited 3 years ago

So I want these unanchored saws to be able to spin on it's spinning axis, the way I want to do this is to use BodyPosition, BodyAngularVelocity and BodyGyro (don't tell me to use while loops to change cframes because I'm avoiding it)

The bodygyro is to prevent the blade from tilting. The hard thing is finding out the math to set the MaxTorque. For the unrotated saw, it's easy to set the MaxTorque as the Y axis is always 0, but for the rotated saw, it's not that simple to figure out.

So what is the math for this?

1 answer

Log in to vote
1
Answered by
Speedmask 661 Moderation Voter
3 years ago
Edited 2 years ago

I hope I don’t sound annoying, but is there anything stopping you from cframing the gyro to match the axis of the saw? it will only make, well, everything easier. you can use the same MaxForce in that respect.

anyways, for the actual question, all you need is the unit vector pointing outwards perpendicular to the axis/normal (I’m assuming you have this, it would be the AngularVelocity value). the MaxForce will be proportionate to that vector, just multiply it. if you’re lucky, this could be any of the three: rightvector, upvector or lookvector depending on how you built the saw. if you STILL do not have the vector you need which I seriously doubt, you will have to do it manually:

the dot product of two perpendicular vectors is 0. you can choose a component of your perpendicular vector to set to 0 (if there isn’t one already) and find the other two components. for example, say this is my normal vector (5, 4, -3) and my perpendicular (x, y, z). I am going to set y to zero and get left with x and z.

5i + 4j - 3k (dot) xi + 0j + zk = 0 simplifies to 5xi - 3zk = 0

now it’s easy. make x = 3 and z = 5 and they cancel out, making 0. so the perpendicular vector is (-3, 0, 5) (just turn it into a unit vector). the secret is to make one pair of components multiply to 0, one pair negative and one pair positive with the same absolute value.

note that in a special case where two components are already 0, such as your first horizontal saw where the normal is (0, 1, 0) then just choose at least one different component like (1, 0, 0) or (1, 0, 1). notice how your own MaxForce is already like that.

again, I do not think you will have to do this because there are so many other ways, but because you asked for a math equation I thought it was worth explaining; for future use.

I also suggest, even though I guess you don’t have to, to use constraints which have replaced the deprecated body movers. BodyPosition, BodyAngularVelocity and BodyGyro have been replaced by AlignPosition, AngularVelocity and AlignOrientation respectively. they’re more intuitive (in my opinion). AlignOrientation has RigidityEnabled which makes this “infinite MaxForce” hack moot.

ps: I thought I recognized that username. yare yare daze :)

Ad

Answer this question