local setmetatable=setmetatable local getmetatable=getmetatable local type=type local clamp=clamp local acos=math.acos local sin=math.sin local cos=math.cos local sqrt=math.sqrt local error=error local min=math.min local max=math.max local abs=math.abs local pow=math.pow local Time=UnityEngine.Time local ToAngle=57.29578 local DoubleToAngle = ToAngle * 2 local ToRad=0.01745329 local Epsilon=0.00001 local Infinite=1/0 local Sqrt2=0.7071067811865475244008443621048490 local PI=3.14159265358979323846264338327950 local destroy = ReusableTable.DestroyVector2 local function clamp(v,min,max) return v>max and max or (v0.999999 end function I:Equal(b) return LuaQuaternion.Dot(self,b)>0.999999 end local creator = ReusableTable.CreateQuaternion function LuaQuaternion.New(x,y,z,w) local q,newCreate = creator() if(newCreate) then q[1],q[2],q[3],q[4] = x or 0,y or 0,z or 0,w or 0 setmetatable(q,I) else q:Set(x,y,z,w) end -- local q={x or 0,y or 0,z or 0,w or 0} -- setmetatable(q,I) return q end function LuaQuaternion.__call(t,x,y,z,w) return LuaQuaternion.New(x,y,z,w) end function get.identity() return LuaQuaternion.New(0,0,0,1) end function get:x() return self[1] end function get:y() return self[2] end function get:z() return self[3] end function get:w() return self[4] end function set:x(v) self[1]=v end function set:y(v) self[2]=v end function set:z(v) self[3]=v end function set:w(v) self[4]=v end local QuaternionGetEulerAngles = VectorHelper.QuaternionGetEulerAngles function get:eulerAngles() return LuaVector3(QuaternionGetEulerAngles(self)) end local QuaternionSetEulerAngles = VectorHelper.QuaternionSetEulerAngles function set:eulerAngles(v) self[1],self[2],self[3],self[4] = QuaternionSetEulerAngles(self,v) end function I:Better_GetEulerAngles(v) v:Set(QuaternionGetEulerAngles(self)) end function I:Set(x,y,z,w) self[1],self[2],self[3],self[4]=x,y,z,w end function I:Clone() return LuaQuaternion.New(self[1],self[2],self[3],self[4]) end function LuaQuaternion.Clone(q) return LuaQuaternion.New(q[1],q[2],q[3],q[4]) end local QuaternionAngleAxis = VectorHelper.QuaternionAngleAxis function LuaQuaternion.AngleAxis(angle,axis) return LuaQuaternion(QuaternionAngleAxis(angle,axis)) end function I:AngleAxis(angle,axis) self[1],self[2],self[3],self[4] = QuaternionAngleAxis(angle,axis) end local QuaternionToAngleAxis = VectorHelper.QuaternionToAngleAxis -- function I:ToAngleAxis() -- local angle,x,y,z = QuaternionToAngleAxis(self) -- return angle,LuaVector3(x,y,z) -- end function I:ToAngleAxis() local angle = acos(self[4])*2 if abs(angle-0)