I was reading a tutorial on inverse kinematics and i stumbled across CFrame:FromAxisAngle.
I read the wiki but sadly im not clearly informed on its purpose.
i was wondering if someone knows what this two functions do and how to use them and if possible explain it with visuals please and thank you.
1 Like
CFrame.fromAxisAngle(Vector3 v,number r)
lets you construct a CFrame rotated r
radians around an axis based on the unit vector v
, or in another way, a direction vector, so say you enter Vector3.new(0,1,0)
, this will be the Y axis, since that vector is looking upwards, and if you enter Vector3 Vector3.new(1,0,0)
, it will be considered the X axis, because the vector is oriented towards the right.
I made a quick example by modifying the orientation of a Part
through its CFrame:
local part = script.Parent -- referencing the Part
part.CFrame = part.CFrame * CFrame.fromAxisAngle(Vector3.new(0,1,0),math.pi/3) -- math.pi/3 is 60 degrees, you could use math.rad(angle in degrees), if you are not familiar with radians.
This script will rotate it 60 degrees around the Y axis, example:
This is the part before being rotated:
After applying the rotation:
For CFrame:ToAxisAngle(), here’s a link to another forum thread:
Hopefully you’ve understood.
15 Likes