When setting gravity the unit is m/s^2
When getting linear velocity the value returned is in px/s
I ran this code to get 2 y-position values and 2 y-velocity values.
physics.setGravity(0,10) projectile = display.newImageRect(layers.content, "images/circle.png", 20, 20 ) projectile.anchorY = 1 projectile.x = centerX - 200 projectile.y = 100 physics.addBody( projectile, "dynamic") local function getValues() local vx, vy = projectile:getLinearVelocity() if projectile.y \< 600 then print("Position Y = " .. projectile.y .. " -- Velocity Y = " .. vy) end end Runtime:addEventListener("enterFrame", getValues)
I then used the UARM motion formula (V2^2 - V1^2) / 2(y-displacement) = acceleration
to get the acceleration
I got 294.44 px/s^2 which is 0.0779 m/s^2 not 10 m/s^2
I figured this is because the y-displacement isn’t the actual number of pixels covered but rather the scaled content area.
So then I converted 10 m/s^2 to px/s^2 and got 3779.5 px/s^2 then used that to get the y-displacement in pixels (V2^2 - V1^2) / 2(acceleration) = y-displacement and got the y-displacement to be 8.589 pixels which makes no sense!
Can someone please me where I went wrong?