Velocity meters per second or pixels per second?

apple documentation gives a physics bodies velocity as in meters per second.

If this is true is there a relationship between pixels and meters? and if there is, what is it?

or is this an error in the documentation and its really pixels per second?

I wrote a small program to try to work this out and got an answer of 135 points to the metre.

Edit: Here is the program for anyone to check to see if my maths is off

//  GameScene.swift
//  gravityTest
//  Created by Steve Ives on 30/05/2016.
//  Copyright (c) 2016 Steve Ives. All rights reserved.

import SpriteKit

class GameScene: SKScene {

//    var elapsedTime: CFTimeInterval = 0.0
    var timeOfLastUpdate: CFTimeInterval = 0.0
    var updateCount = 0
    let sprite = SKSpriteNode(imageNamed:"Spaceship")

    override func didMove(to view: SKView) {
        /* Setup your scene here */

//        physicsWorld.gravity = CGVectorMake(-9.8, 0)

        let location = CGPoint(x: (scene?.frame.midX)!, y: (scene?.frame.midY)!)

        sprite.xScale = 0.5
        sprite.yScale = 0.5

        sprite.physicsBody = SKPhysicsBody(rectangleOf: sprite.size)
        sprite.physicsBody?.isDynamic = true
        sprite.position = location


    override func update(_ currentTime: CFTimeInterval) {
        /* Called before each frame is rendered */
                updateCount += 1
        if (currentTime - timeOfLastUpdate) < 1 {return}

//        if (timeOfLastUpdate - currentTime > 1.0) {
        print("\(updateCount) - Time : \(currentTime) \(currentTime-timeOfLastUpdate) Location is : \(sprite.position) Velocity is : \(sprite.physicsBody!.velocity)")
//        }

        timeOfLastUpdate = currentTime

Converting the velocity of a point from pixels/second to metres , However, I'm having a few issues namely: I'm not quite sure my velocity estimation in pixels per second is correct. My current code for estimating velocity is: Meters per second is a unit of Speed or Velocity in the Metric System. It measures the number of meters traveled in a second. The symbol for meters per second is m/s and the International spelling for this unit is metres per second.

I used playground to calculate my distance. I am getting around 150

We know distance is d = (gt^2)/2 where g is gravity and t is time.

d = (9.8m/t^2)(t^2)/2 d = (9.8m)/2 d = 4.9m

In 1 second, we would travel 4.9m

In our case, we travelled 765.9298706054688 points.

765.9298706054688/4.9 gets us around 156.312218491.

Ideally, we would have travelled 735 points, not sure what in my code could cause a 30 point difference, I suspect it has to do with SKAction

//: A SpriteKit based Playground

import PlaygroundSupport
import SpriteKit

class GameScene: SKScene {

    private var testNode = SKSpriteNode(color: .red, size: CGSize(width: 20, height: 20))
    private var flag = false
    private var time : CGFloat = 0
    private var beginTest = false
    override func didMove(to view: SKView) {


    @objc static override var supportsSecureCoding: Bool {
        // SKNode conforms to NSSecureCoding, so any subclass going
        // through the decoding process must support secure coding
        get {
            return true

    func touchDown(atPoint pos : CGPoint) {

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        testNode = SKSpriteNode(color: .red, size: CGSize(width: 20, height: 20))
        let physicsBody = SKPhysicsBody(rectangleOf: testNode.size)
        physicsBody.angularDamping = 0
        physicsBody.linearDamping = 0
        physicsBody.friction = 0
        testNode.physicsBody = physicsBody
        let action = SKAction.customAction(withDuration: 2)
            node,elapsedTime in
            if elapsedTime >= 1 && !self.flag && self.time == 0{
                self.flag = true
                self.time = elapsedTime
        beginTest = true

    override func update(_ currentTime: TimeInterval) {
        if beginTest{
            beginTest = false
    override func didFinishUpdate() {


    override func didApplyConstraints() {
        if flag{
            let position = CGPoint(x:testNode.position.x,y:-testNode.position.y)

            print("Node traveled \(position.y) points over \(time) seconds with a velocity of \(testNode.physicsBody!.velocity)")

            let pointsPerMeter = -testNode.physicsBody!.velocity.dy/9.8
            print("Node traveled \(pointsPerMeter) points per meter over \(time) seconds with a velocity of \(testNode.physicsBody!.velocity)")
            flag = false
            time = 0

// Load the SKScene from 'GameScene.sks'
let sceneView = SKView(frame: CGRect(x:0 , y:0, width: 640, height: 480))
if let scene = GameScene(fileNamed: "GameScene") {
    // Set the scale mode to scale to fit the window
    scene.scaleMode = .aspectFill

    // Present the scene

PlaygroundSupport.PlaygroundPage.current.liveView = sceneView

Node traveled 765.9298706054688 points over 1.0 seconds with a velocity of (0.0, -1494.4998779296875) Node traveled 152.49998754384566 points per meter over 1.0 seconds with a velocity of (0.0, -1494.4998779296875)

How to convert optical flow velocity to meters per second?, However, I would like to convert the velocities from pixels/frame to meters/sec. How can I do this? Obviously I tried. diff(position)/fps. but this magnifies noise in� I understand that velocity is measured in meters/second. I suppose this is a remnant of Unity's 3D roots where the world should operate independent of the scale of the viewport. For 2D games this makes less sense, so I would like to calculate / set the speed of objects in pixels per second.

An answer to anyone and myself

There is nothing to really define a pixel within apples SKSpriteKit, this is a misnomer in my question. A point on the other hand is well defined.

Everybody probably already knows this but if you attach a SKPhysicsBody to a Node and assign the following properties:

    seg.physicsBody?.isDynamic = true
    seg.physicsBody?.affectedByGravity = false
    seg.physicsBody?.allowsRotation = false
    seg.physicsBody?.usesPreciseCollisionDetection = true
    seg.physicsBody?.mass = 0
    seg.physicsBody?.restitution = 1
    seg.physicsBody?.linearDamping = 0

Then applying a velocity dy component of 200 results in the object moving at 200 points per second. This says to me that with all external forces remove Sprite kits physics world translates to 1m/s = 1point/s.

How set 2D velocity in pixels?, I understand that velocity is measured in meters/second. I suppose this is a remnant of Unity's 3D roots where the world should operate� Instantly Convert Meters Per Second (m/s) to Meters Per Minute (m/min) and Many More Speed Or Velocity Conversions Online. Meters Per Second Conversion Charts. Many Other Conversions.

Convert inches per second to meters per second, This on the web one-way conversion tool converts speed and velocity units from inches per second ( in/sec ) into meters per second ( m/sec ) instantly online. Feet per second . Feet per second to Meters per second formula Meters per second. The SI measurement of speed and velocity. This is the number of meters travelled in one second of time. The accompanying acceleration unit is meters per second per second (m/s²).

Convert speed of light to meters per second, This on the web one-way conversion tool converts speed and velocity units from speed of light ( c 0 ) into meters per second ( m/sec ) instantly online. 1 speed of� foot per second: ft/s, fps: 0.3048 m/s: furlong per fortnight: furlong/fortnight: 1.66309×10 −4 m/s: inch per second: in/s, ips: 2.54×10 −2 m/s: kilometer per hour: km/h: 0.277778 m/s: knot (noeud) kn, knot: 0.514444 m/s: kyne: cm/s: 1×10 −2 m/s: meter per minute: m/min: 1.66667×10 −2 m/s: meter per second: m/s: 1 m/s: mil per year

How to find the Velocity and Acceleration between two frames in , To find the velocity, you need to calculate the position of the object of interest in to know "real-world" velocity, you need the scaling factor (meters to pixels) as well. Video analysis at 1000 frames per second was used to analyse distance, � Use this velocity converter to convert instantly between centimeters per second, feet per hour, kilometers per hour, knots, meters per second, miles per hour and other metric and imperial velocity and speed units.

  • The documentation on area says: "The value returned for the area is measured in meters: if you need to convert it into points — as used by SpriteKit — multiply the values by 150²." So you could probably figure it out from there.
  • thanks where did you get the number 150^2 from ?
  • From the above linked documentation on the area function.…
  • wow thanks again
  • it isnt 150^2. Area is 150^2 because it involves a length and width. Velocity is a vector, so it is only 150
  • Are you sure about your times here? You are 1 frame off from your results being 150. DId you save this program by chance?
  • @Knight0fDragon interesting... I should have; I’ll save if I can find it.
  • I posted my code as well, seems we have a timing discrepency here between you and me.
  • You are using the next update cycle instead of capturing it during the cycle it moved, perhaps that is what is throwing off your numbers?
  • I’ll have a play - If Apple say it’s 150 then obviously that is the figure we should believe first. Need to get back into coding after changing jobs but I have my new (to me) Mac Pro 2013 to play with 😀