IronNoob

Please login or register.

Login with username, password and session length
Advanced search  

News:

Migrated to dedicated hosting. Post any weirdness you observe in the Lounge.

Author Topic: Question about CFraming  (Read 87 times)

0 Members and 1 Guest are viewing this topic.

gauthierhaas

  • Newbie
  • *
  • Offline Offline
  • Posts: 19
    • View Profile
Question about CFraming
« on: April 14, 2013, 07:59:21 am »

We can modify the Angle of a part by putting:
part.CFrame = part.CFrame * CFrame.Angles(x, y, z).
But is there any way to get the current rotation of the part in x, y and z?

(CFrame.lookVector gives a Vector3 value, but how can we "translate" it into rad angles?)
« Last Edit: April 14, 2013, 09:41:42 am by gauthierhaas »
Logged
A mind is like a parachute, it's only good when its open

BAUER102

  • Full Member
  • ***
  • Offline Offline
  • Posts: 199
  • Full-time God
    • View Profile
Re: Question about CFraming
« Reply #1 on: April 14, 2013, 10:50:38 am »

if you want the rotation to work with it:

Code: [Select]
local rotation = MyCFrame - MyCFrame.p

If you want to have the actual numbers, use:

Code: [Select]
local rotation = {MyCFrame:toEulerAnglesXYZ()}

http://wiki.roblox.com/index.php/CFrame
Logged
German Coding Maniac
Main Twitter || Borderline Twitter || ROBLOX Account

gauthierhaas

  • Newbie
  • *
  • Offline Offline
  • Posts: 19
    • View Profile
Re: Question about CFraming
« Reply #2 on: April 14, 2013, 10:51:58 am »

Okay thank you
Logged
A mind is like a parachute, it's only good when its open

gauthierhaas

  • Newbie
  • *
  • Offline Offline
  • Posts: 19
    • View Profile
Re: Question about CFraming
« Reply #3 on: April 14, 2013, 03:10:53 pm »

Hum...
"local rotation = MyCFrame - MyCFrame.p"
gives me a 3*3 rotation matrix, not the x y z coordinates for the rotation

"print({MyCFrame:toEulerAnglesXYZ()})" returns (as an example): "table: 18BE3568", which is no xyz coordinates either.
Logged
A mind is like a parachute, it's only good when its open

spacek531

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1188
  • Building Roblox coasters since 2008
    • View Profile
Re: Question about CFraming
« Reply #4 on: April 14, 2013, 03:43:59 pm »

Hum...
"local rotation = MyCFrame - MyCFrame.p"
gives me a 3*3 rotation matrix, not the x y z coordinates for the rotation

"print({MyCFrame:toEulerAnglesXYZ()})" returns (as an example): "table: 18BE3568", which is no xyz coordinates either.

there really aren't any xyz coordinates for rotation. There are better ways of getting the rotation matrix (the 3x3 matric) and using it than toEulerAnglesXYZ(). Also, don't wrap the MyCFrame:toEulerAnglesXYZ() in curly brackets, that makes it a table.
Logged
my race track
Now with less lag and less understeer!

Void_Knight

  • Man of Mystery
  • Global Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 9602
  • Nope, Void_Knight.
    • View Profile
Re: Question about CFraming
« Reply #5 on: April 14, 2013, 04:36:51 pm »

If you want to turn a lookVector into a CFrame, you do
local lookCoords = CFrame.new(part.CFrame.lookVector);

might be what you want, might not be. Just thought I'd share now to turn a lookVector into a CFrame.

You should be able to just multiply it by the lookCoords and it should rotate it as appropriate.
Logged

BAUER102

  • Full Member
  • ***
  • Offline Offline
  • Posts: 199
  • Full-time God
    • View Profile
Re: Question about CFraming
« Reply #6 on: April 15, 2013, 05:03:32 am »

Hum...
"local rotation = MyCFrame - MyCFrame.p"
gives me a 3*3 rotation matrix, not the x y z coordinates for the rotation

"print({MyCFrame:toEulerAnglesXYZ()})" returns (as an example): "table: 18BE3568", which is no xyz coordinates either.

that's a table, duh

local x, y, z = table[1], table[2], table[3]

Logged
German Coding Maniac
Main Twitter || Borderline Twitter || ROBLOX Account

gauthierhaas

  • Newbie
  • *
  • Offline Offline
  • Posts: 19
    • View Profile
Re: Question about CFraming
« Reply #7 on: April 15, 2013, 08:58:36 am »

What i wanna do is the following:
"
part = thePartIWannaAnimate

initialX = int
initialY = int
initialZ = int

finalX = int
finalY = int
finalZ = int
nbFrames = int

i, j, k = initialX, initialY, initialZ

repeat
     part.CFrame.Rotation = Rotation.new(i, j, k) --I know this command doesn't exist, it's just to show you what i am looking for
     i = initialX + (finalX - initialX)/nbFrames
     j = initialY + (finalY - initialY)/nbFrames
     k = initialZ + (finalZ - initialZ)/nbFrames
     wait()
until (i > finalX)
"

This would basically just smoothly animate a part by rotating it from a predefined rotation to another one
Logged
A mind is like a parachute, it's only good when its open
 

Page created in 0.089 seconds with 22 queries.