generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How can you extract EulerAngles (radians in X, Y, and Z) from a part's CFrame?

Previous Thread :: Next Thread 
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
05 Sep 2011 09:03 AM
This would really help me a lot.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
05 Sep 2011 09:25 AM
This wouldn't help at all. Why do you want to do this? What do you intend to use these angles for?

I bet you that "EulerAngles" does not mean what you think it does.

Report Abuse
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
05 Sep 2011 09:31 AM
Brick.CFrame = CFrame.new(x,y,z) * CFrame.Angles(rx,ry,rz)

I want the brick to be in a specific Vector3D position, yet have a rotation of different brick. I need to find the three radians (which are rx, ry, and rz) of THAT brick.

I know what it means, durr. Why would I even bother asking?
Report Abuse
GalaxyWarriors is not online. GalaxyWarriors
Joined: 27 Aug 2011
Total Posts: 36
05 Sep 2011 09:31 AM
local X,Y,Z = CFrameValue:toEulerAnglesXYZ()
Report Abuse
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
05 Sep 2011 09:32 AM
I'll try that.
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
05 Sep 2011 09:33 AM
You will find something in the wiki.
Report Abuse
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
05 Sep 2011 09:34 AM
I already tried CFrameValue:toEulerAnglesXYZ() before, but it only returned a number. I even tried extracting every value in the matrix.
Report Abuse
GalaxyWarriors is not online. GalaxyWarriors
Joined: 27 Aug 2011
Total Posts: 36
05 Sep 2011 09:36 AM
It returns 3 numbers.

CF = CFrame.new(1,2,3) * CFrame.Angles(AnotherCFrame:toEulerAnglesXYZ())
Report Abuse
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
05 Sep 2011 09:45 AM
Amazing, it worked.

Thanks.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
05 Sep 2011 09:46 AM
> I know what it means, durr. Why would I even bother asking?

Explain what it means then. I know that you "think" you know what it means, but I bet your meaning is wrong

> I want the brick to be in a specific Vector3D position, yet have a rotation of different brick

There's a much easier way of doing that:

    local rotation = brick1.CFrame - brick1.CFrame.p
    brick2.CFrame = CFrame.new(1, 2, 3) * rotation
Report Abuse
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
05 Sep 2011 09:51 AM
Well, I didn't ask help here because I know it already, right?

Also, I think that would work, too. Also, at least I learned something new from the other method.

Anyways, thanks. I guess I also learned something from you (didn't know you can just subtract the position, so you can only include the angles).
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
05 Sep 2011 09:56 AM
> Also, at least I learned something new from the other method.

While that's true, I would argue that you should never have to use :fromEulerAngles, short of wanting to tell the player EulerAngles.

Seriously, look up Euler Angles on wikipedia. They probably don't work how you might think they do. They're actually another name for "Yaw, pitch, and roll", which is the system used by airplanes. What `.Angles` / `.fromEulerAnglesXYZ` actually means is

    CFrame.Angles(pitch, yaw, roll)
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
05 Sep 2011 09:59 AM
Roblox made it easier for us by using the xyz system. Whoever thought of making it yxz was a bit nutty.
Report Abuse
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
05 Sep 2011 10:00 AM
But then I found another problem where I need to subtract the Y by 90 degrees (pi/2) since it was oriented in the wrong direction.

I guess I can do that in my own way easier in the other method.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
05 Sep 2011 10:04 AM
Still no. You now want:

    local rotation = brick1.CFrame - brick1.CFrame.p
    brick2.CFrame = CFrame.new(1, 2, 3) * CFrame.Angles(0, math.pi / 2, 0)
                                        * rotation
Report Abuse
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
05 Sep 2011 10:08 AM
Yours:
local rotation = brick1.CFrame - brick1.CFrame.p
brick2.CFrame = CFrame.new(1, 2, 3) * CFrame.Angles(math.pi / 2, math.pi / 2, 0) * rotation

Mine:
local rx, ry, rz = RayPart.CFrame:toEulerAnglesXYZ()
Body.Center.CFrame = CFrame.new(Body.Center.Position) * CFrame.Angles(rx + (math.pi)/2,ry + (math.pi)/2,rz)

I guess yours is shorter by a little bit, and I can still modify yours easy.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
05 Sep 2011 10:14 AM
This proves you don't understand EulerAngles.

My way results in a different pitch to yours. The thing to know is:

    CFrame.Angles(x1, y1, z1) * CFrame.Angles(x2, y2, z2) ~= CFrame.Angles(x1 + x2, y1 + y2, z1 + z2)
Report Abuse
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
05 Sep 2011 10:18 AM
Eh, I wouldn't know something that's not in the wiki (At least I can't find it. I'm sure you know where it is, your primary group should say so).

Anyways, I think I've learned something.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
05 Sep 2011 10:20 AM
> I wouldn't know something that's not in the wiki - At least, I can't find it.

It's not on the wiki in any great detail. I'm having difficulty seeing how to describe in a non-confusing way. But essentially, most peoples initial way at looking at it is wrong.

> Anyways, I think I've learned something.

Glad to hear it.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image