CFrame Rotations - how does the grid work?

Howdy developers,

Today I come to you seeking advice. I’m in the process of trying to make an accessory a player can manipulate via translation and rotation. It’s done by changing the C0 of the “AccessoryWeld”. I’m trying to keep it simple for the player by having 3 dimensions for translation and 3 angles for rotation - X/Y/Z. My problem is that I completely forgot how rotation matrices work. I took a class on it in college but I haven’t had to use that knowledge until now. There’s a grid of 3x3 numbers here, when what I need is simply 3 numbers (degrees rotation).

In my ideal world, rotations would start at 0,0,0. If they drag the X to be 90, then the rotations become 90,0,0 and the C0 of the accessory is rotated 90 degrees on the X axis. How would I accomplish converting a player’s input of ‘degrees’ into the CFrame matrix?

I need a method to both convert 3 rotations into a CFrame, as well as a method to convert a CFrame into the 3 rotations. Roll, pitch, and yaw is a good description of the rotations I’m going for, I think.

1 Like

cant you just use CFrame.fromEulerAnglesXYZ(0,0,0) then use a math.rad to rotate CFrame?

So you’re saying use CFrame.fromEulerAnglesXYZ(x, y, z) to convert the player’s input rotations into the matrix?

Could the CFrame also be converted back into rotation angles using CFrame.toEulerAnglesXYZ()?