local X={}function X.Lerp(X,F,e)if typeof(X)~="\086\101\099\116\111\114\051"then X=X.Position end if typeof(F)~="\086\101\099\116\111\114\051"then F=F.Position end return X+(F-X)*e end function X.GetFrameByDistance(X,F,e)if typeof(X)~="\086\101\099\116\111\114\051"then X=X.Position end if typeof(F)~="\086\101\099\116\111\114\051"then F=F.Position end if not e then e=1 else e=1+e end local D=(X-F).Magnitude local j=math.round((D*2)/e)return j end function X.GetMotionTime(X,F)local e=0 e+=task.wait(1/F)*X return e end function X.GetMiddlePosition(X,F,e,D)if typeof(X)~="\086\101\099\116\111\114\051"then X=X.Position end if typeof(F)~="\086\101\099\116\111\114\051"then F=F.Position end if not e then e=0 end if not D then D=1 else D=1+D end local j=(X-F)*.5 local w=X-j local A=CFrame.new(w,F)A=A*CFrame.Angles(0,0,math.rad(e))local E=j.Magnitude*D local R=w+A.UpVector*E return R end function X.Get2MiddlePosition(X,F,e,D,j,w)if typeof(X)~="\086\101\099\116\111\114\051"then X=X.Position end if typeof(F)~="\086\101\099\116\111\114\051"then F=F.Position end if not e then e=0 end if not j then j=0 end if not D then D=1 else D=1+D end if not w then w=1 else w=1+w end local function A(X,F,e,D,j)local w=(X-F)*j local A=X-w local E=CFrame.new(A,F)E=E*CFrame.Angles(0,0,math.rad(e))local R=w.Magnitude*D local Z=A+E.UpVector*R return Z end local E=A(X,F,e,D,.33333333333333)local R=A(X,F,j,w,.66666666666667)return E,R end

local BezierCurve = {}

function BezierCurve.Lerp(Start , End , Time)

	if typeof(Start) ~= "Vector3" then
		Start = Start.Position
	end

	if typeof(End) ~= "Vector3" then
		End = End.Position
	end

	return Start + (End - Start) * Time

end

function BezierCurve.GetFrameByDistance(Start , End , Multiply)

	if typeof(Start) ~= "Vector3" then
		Start = Start.Position
	end

	if typeof(End) ~= "Vector3" then
		End = End.Position
	end

	if not Multiply then
		Multiply = 1
	else
		Multiply = 1 + Multiply
	end

	local Distance = (Start - End).Magnitude--æ—‹è½¬åŠå¾„
	local Frame = math.round(Distance * 2 / Multiply)

	return Frame

end

function BezierCurve.GetMotionTime(Frame , FPS)
	local Time = 0

	Time += task.wait(1 / FPS) * Frame

	return Time
end

function BezierCurve.GetMiddlePosition(StartPosition , TargetPosition , Angle , Offset)

	if typeof(StartPosition) ~= "Vector3" then
		StartPosition = StartPosition.Position
	end

	if typeof(TargetPosition) ~= "Vector3" then
		TargetPosition = TargetPosition.Position
	end

	if not Angle then
		Angle = 0
	end

	if not Offset then
		Offset = 1
	else
		Offset = 1 + Offset
	end

	local HalfVector3 = (StartPosition - TargetPosition) * 0.5 --èµ·å§‹ä¸Žç›®æ ‡ä¹‹é—´ä¸€åŠé•¿åº¦çš„å‘é‡
	local MiddlePosition = StartPosition - HalfVector3 --ä¸­é—´ä½ç½®ç‚¹
	local RotateCFrame = CFrame.new(MiddlePosition,TargetPosition) --ä»Žèµ·å§‹ä¸Žç›®æ ‡ä¹‹é—´çš„ä¸­å¿ƒç‚¹æŒ‡å‘ç›®æ ‡çš„å‘é‡,ç”¨æ­¤å‘é‡è¿›è¡Œæ—‹è½¬

	RotateCFrame = RotateCFrame * CFrame.Angles(0,0,math.rad(Angle)) --æ ¹æ®è§’åº¦æ—‹è½¬æ­¤å‘é‡
	local Radius = HalfVector3.Magnitude * Offset--æ—‹è½¬åŠå¾„

	local ResultPosition = MiddlePosition + RotateCFrame.UpVector * Radius --ä¸­é—´ä½ç½® + æ—‹è½¬åŽçš„ä¸Šæœå‘ * åŠå¾„

	return ResultPosition

end

function BezierCurve.Get2MiddlePosition(StartPosition , TargetPosition , Angle1 , Offset1 , Angle2 , Offset2)

	if typeof(StartPosition) ~= "Vector3" then
		StartPosition = StartPosition.Position
	end

	if typeof(TargetPosition) ~= "Vector3" then
		TargetPosition = TargetPosition.Position
	end

	if not Angle1 then
		Angle1 = 0
	end

	if not Angle2 then
		Angle2 = 0
	end

	if not Offset1 then
		Offset1 = 1
	else
		Offset1 = 1 + Offset1
	end

	if not Offset2 then
		Offset2 = 1
	else
		Offset2 = 1 + Offset2
	end

	local function GetResultPosition(StartPosition , TargetPosition , Angle , Offset , Length)

		local HalfVector3 = (StartPosition - TargetPosition) * Length --èµ·å§‹ä¸Žç›®æ ‡ä¹‹é—´ä¸‰åˆ†ä¹‹ä¸€é•¿åº¦çš„å‘é‡
		local MiddlePosition = StartPosition - HalfVector3 --ä¸­é—´ä½ç½®ç‚¹
		local RotateCFrame = CFrame.new(MiddlePosition,TargetPosition) --ä»Žèµ·å§‹ä¸Žç›®æ ‡ä¹‹é—´çš„ä¸­å¿ƒç‚¹æŒ‡å‘ç›®æ ‡çš„å‘é‡,ç”¨æ­¤å‘é‡è¿›è¡Œæ—‹è½¬

		RotateCFrame = RotateCFrame * CFrame.Angles(0,0,math.rad(Angle)) --æ ¹æ®è§’åº¦æ—‹è½¬æ­¤å‘é‡
		local Radius = HalfVector3.Magnitude * Offset--æ—‹è½¬åŠå¾„

		local ResultPosition = MiddlePosition + RotateCFrame.UpVector * Radius --ä¸­é—´ä½ç½® + æ—‹è½¬åŽçš„ä¸Šæœå‘ * åŠå¾„
		return ResultPosition
	end

	local ResultPosition1 = GetResultPosition(StartPosition , TargetPosition , Angle1 , Offset1 , 1/3)
	local ResultPosition2 = GetResultPosition(StartPosition , TargetPosition , Angle2 , Offset2 , 1/3 * 2)

	return ResultPosition1 , ResultPosition2

end
