Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vector.Animation.CircularMotion = function(_self,_center,_speed)
- --[[
- CircularMotion takes a position a center and a speed,
- given the position and center, find a vector dif from center to start_vec,
- use the magnitude of dif to find the circle radius, use the angle between the components of dif to find the start location on the circle,
- set the step to the appropriate starting location
- ]]--
- local dif = _center - _self
- local radius,step = Vector.magnitude(dif), atan2(dif.x,dif.y)*framerate/_speed
- local function update(_end)
- while not _end do
- step += 1
- _self:Set(-cos((step/framerate)*_speed)*radius + _center.x,-sin((step/framerate)*_speed)*radius + _center.y)
- yield()
- end
- end
- return cocreate(update)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement