# How to learn about CFrame and math

Hello, so I speak spanish, and it’s like, I speak really good english I understand it, but, on the dev wiki, is kinda hard to understand, so I was wondering, what CFrame angles could be user for? It’s hard to understand CFrame? Is CFrame a combination of Position and Orientation? What is CFrame, also, what’s math.rad and math.floor? I’ve been looking for the answers, but, it’s just too complicated, sorry about a lot of questions
Like, I mean
On devwiki about CFrame.Angles it says: Equivalent to fromEulerAnglesXYZ ???

CFrames are an abstraction of 4x4 matrices which represent position and rotation. You are correct that they represent this.

Also `math.rad` is a function that takes a number in degrees; `math.rad(180) == math.pi` because pi radians = 180 degrees. The `CFrame.Angles` constructor treats its arguments as radians, which is why you do the conversion.

1 Like

CFrame is technically, yes, a combination of Position and Orientation. `CFrame.new(Vector3 pos, Vector3 orientation)`
`math.floor` rounds down to the nearest whole number.
`math.rad` converts degrees to radians.

`CFrame.Angles` works in radians so if you are familiar with degrees, you can use `math.rad`
Multiplying CFrame is basically Adding to it, so

Using `CFrame.Angles`, we can rotate a CFrame.

Example
`CFrame.new(0,0,0) * CFrame.Angles(0, math.rad(90), 0)` - This is basically rotating the CFrame 90 degrees in the Y axis.

1 Like

Hey so, question

``````local relPos = Hitbox.CFrame:pointToObjectSpace(HRP.Position)
print('Interacted with Door')
if relPos.Z >= 0 then
print('Back')
InteractableEvent:FireServer('OpenDoorBack')
elseif relPos.Z <= 0 then
print('Front')
InteractableEvent:FireServer('OpenDoorFront')
end
``````

What does :PointToObjectSpace() do? How does it detects if you’re on a back or in front of a position

Another question… sorry, so, math.floor doens’t does anything I think? like, print(math.floor(50/2)) it’s the same, wdym rounds down to the nearest whole number?

`pointToObjectSpace` returns a Vector3 Value that was in world space and puts it into object space.
The same thing would happen if you did `Hitbox.CFrame:inverse() * HRP.Position`
It detects it because that’s what Object space is, well I can’t explain it, sorry.

2 Likes

`math.floor` returns it rounded down to the nearest whole number

Example:
`math.floor(25.35)` Returns 25

`math.floor(25.88)` Returns 25
`math.floor(25.02)` Returns 25

2 Likes

Oh!!! Alrighty, that’s really good, I was just making a speed radar doing

``````object.Velocity.Magnitude/2
``````

And it returned sometimes 25.1 40.5 and stuff, with math.floor it will work!! that’s nice ty.

1 Like

For future reference in case you have any questions on it,
`math.ceil` does the exact opposite.

Example:
`math.ceil(25.35)` Returns 26
`math.ceil(25.88)` Returns 26
`math.ceil(25.02)` Returns 26

2 Likes

Wdym, isn’t it doing the same? like it returns the nearest whole number?

No. It doesn’t round “to the nearest whole number” (my bad lol).
`math.floor` rounds down.
`math.ceil` rounds up.

all to the whole number