jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
|
| 23 May 2017 02:53 PM |
I want to convert a specific axis of a CFrame object to degrees. After looking over the documentation, I'm lost for which method I should use to accomplish this. I've experimented with :toAxisAngle() and :EulerAnglesXYZ(), but I'm uncertain of what they actually return. Could someone either explain them more in-depth or tell me other methods to accomplish my goal?
For example what I want to do.
local c = CFrame.new(pos1, pos2);
print(c:WhatMethodShouldIUse().Y) -- -180 <= Angle of the Y-axis <= 180 |
|
|
| Report Abuse |
|
|
|
| 23 May 2017 02:59 PM |
| they return the rotational components x,y,z in radians local x,y,z = c:toEulerAnglesXYZ() however u probably should not be using orientation, and instead just use cframe for accuracy object.CFrame = ##################### - pos1 + object.CFrame.p --gets rid of the position and moves it back |
|
|
| Report Abuse |
|
|
|
| 23 May 2017 03:00 PM |
they return the rotational components x,y,z in radians
local x,y,z = c:toEulerAnglesXYZ()
however u probably should not be using orientation, and instead just use cframe for accuracy
object.CFrame = CFrame.new(position1, position2) - position1 + object.CFrame.p --gets rid of the position and moves it back |
|
|
| Report Abuse |
|
|
jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
|
| 23 May 2017 03:04 PM |
| I'm actually intending to convert roblox's rotation to 0 -> 360 to rotate a gui. |
|
|
| Report Abuse |
|
|
|
| 23 May 2017 03:06 PM |
on which axis? if u want like a gps then do
math.deg( math.atan2( lookVector.Z, lookVector.X ) ) |
|
|
| Report Abuse |
|
|
|
| 23 May 2017 03:06 PM |
| since it forms a right triangle it finds the angle between those 2 legs in case u were wondering "WHY" |
|
|
| Report Abuse |
|
|
jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
|
| 23 May 2017 03:08 PM |
| Hehe, you saw through my plan, I wasn't sure on how arch tangent work so I was using that hacky method. Thanks for the help by the way. |
|
|
| Report Abuse |
|
|
|
| 23 May 2017 03:10 PM |
goo.gl/m8lQxT
explains why
and the reason why X and Z is because that is rotation based on the Y axis |
|
|
| Report Abuse |
|
|