-- Inverse Kinematics will require profecient knowledge of trig and potentially calculus to understand completely.



local pi			=math.pi -- We are using radian-based angles (rather than degree), so we use pi! pi radians = 180 degrees
local hpi			=pi/2 -- pi/2 radians = 90 degrees
local tau			=2*pi -- 2pi radians = 360 degrees

local CF			=CFrame.new -- We don't want to type CFrame.new over and over
local V3			=Vector3.new -- We don't want to type Vector3.new over and over
local ANGLES		=CFrame.Angles -- Again, so we don't have to repeat it
local fromAxisAngle	=CFrame.fromAxisAngle -- Lol again
local NC			=CF() -- Get a blank cframe, same as Cframe.new(0,0,0)
local NV			=V3() -- Get a blank vector3, same as Vector3.new(0,0,0)
local forwardV3		=V3(0,0,-1) -- Get a forward-directional Vector3
local x_and_y		=V3(1,0,1) -- This will be used later; Vector3*x_and_y will remove the middle value, or the y-value.

local rhipcf		=CFrame.new(0.5, -0.4, 0) -- The right-hip reference CFrame, relative to the RightUpperLeg position
local lhipcf 		=CFrame.new(-0.5, -0.4, 0) -- The left-hip reference CFrame, relative to the LeftUpperLeg position
local rhipcf2 		=CFrame.new(0.5,-2.5,0)
local lhipcf2 		=CFrame.new(-0.5,-2.5,0)

local rIdle			=CFrame.new(0.25,-1.9,0) -- Idle CFrame of Motor6D joint
local lIdle			=CFrame.new(-0.25,-1.9,0) -- Idle CFrame of Motor6D joint
