Jump to content




Gravity Manipulation Questions


  • You cannot reply to this topic
20 replies to this topic

#21 GopherAtl

  • Members
  • 888 posts

Posted 21 January 2015 - 04:07 PM

I see no mistakes there. As I said, you'll have to extend it to 2 dimensions, which will make that particular function more like this...

local function evaluate( initial,  t,  dt, d )
local state = { x = initial.x + d.dx * dt,   y=initial.y + d.dy*dt,
	vx = initial.vx + d.dvx * dt, vy=initial.vy+d.dvy*dy }
local output = {}
output.dx = state.vx
output.dy=state.vy
output.dvx, output.dvy = acceleration(state, t+dt) --assuming updated acceleration returns x,y
return output;
end
Or, if you wanted to use the vector API...
and changed "x" to "p" for position

local function evaluate( initial,  t,  dt, d )
local state = { pos = initial.pos + d.dx * dt, v  = initial.v + d.dv * dt }
local output = {}
output.dp = state.v
output.dv, = acceleration(state, t+dt) --assuming updated acceleration returns a vector
return output;
end


With the vector api version, you have to make a new vector with vector.new(xval,yval) (you can just ignore z, leaving it at 0 for all) so you would set up your initial state something like:
(changing "x" to "p" for pos, leaving v for velocity)
local initialState = { p = vector.new(10,10), v=vector.new(0,0) }

Edited by GopherAtl, 21 January 2015 - 04:13 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users