내가 뭘 하려는지, 키네틱 모델을 사용하여 멋진 스크롤 막대를 만드는 것입니다. 문제는 오버 슛으로 약화되고 있습니다. 내가 보여주고 싶은 행동은 당신이 오버 슛 (최대/최소를 지나쳐) 할 때, 포지셔닝을 약화시키는 것입니다.스크롤링 오버 슛 오버 슈트 - 수학 문제
내가 원하는 특정 동작은 다음과 같습니다. 즉, Maximumum Overshoot는 50 픽셀입니다. 어떻게 작동시키고 싶은지를 나타내는 표가 있습니다. (이것은 내가 생각할 수있는 가장 좋은 방법이다.)
Displacement | Position it | Percent
of position | Displays @ | Overshot Over
-------------------------------------------------
25 | 12.5 | 50%
100 | 25 | 100%
200 | 37.5 | 200%
400 | 43.75 | 400%
... ... ...
Note: Decimals would obviously round down so we can actually display it.
저는 이것을 재귀 적으로 계산할 수 있다고 확신합니다.하지만 그렇게하고 싶지는 않습니다. 나는 수학적 관계가 상당히 명백하다고 생각하지만, 어떻게해야하는지 정확하게 모르겠습니다. 나는 이것이 잘못된 방식으로 생각할 수도 있으므로 내 차트를 무시하십시오.중요 건데 사용자는 최대 오버 슛 값 (이 경우 50 픽셀)을 지나서 창을 이동할 수 없습니다.
다음은 주요 문제는 내가 그것을 표시해야 변위를 찾을 수있는 수학적 방법을 찾기 위해 노력하고있다
function KineticModel:SetPosition(NewPosition)
-- Set's the position of the kinetic model. Using this, it'll calculate velocity.
local CurrentTime = tick()
local ElapsedTime = CurrentTime - self.TimeStamp
local LocalVelocity = ((self.Position - self.LastPosition) * 5)/ElapsedTime
TimeStamp = CurrentTime
self:SetVelocity((0.2 * self.Velocity) + (0.8 * LocalVelocity)) -- 20% previous velocity maintained, 80% of new velocity used.
if NewPosition > self.Maximum then
print("[KineticModel] - Past Max Manual")
local Displacement = math.abs(NewPosition - self.Maximum)
-- Dampen position so it can't go over.
self.Position = self.Maximum + (Displacement/self.MaxBounce) -- This doesn't work. :(
elseif NewPosition < self.Minimum
print("[KineticModel] - Past Min Manual")
local Displacement = math.abs(NewPosition - self.Minimum)
-- Same displacement here
else
self.Position = NewPosition
end
self.LastPosition = self.Position
self.OnPositionChange(self.Position)
print("[KineticModel] - Set Velocity @ "..self.Velocity.."; Local Velocity @ "..LocalVelocity)
end
... 위치 설정을 실행하는 코드 세그먼트입니다. 모든 위치에 설정되기 전에 기본적으로 위치를 필터링하도록이 위치 변경을 구현할 예정입니다. 따라서 잠재적 인 문제가있는 경우 알려주세요.
감사합니다. : D
편집 : 제목,이 대답은 그래서 속도와 완충 및 대한 모든 동적 측면을 무시