calculating the distance between two physics objects

hello everyone;

how can i calculate (or read) the distance(meter-based) between two physics objects.

thanks for your help :slight_smile:

This is the Pythagorean Theorem caluculation from Algebra. See:

http://www.mathopenref.com/coorddist.html

Converted to Lua:

local dX = math.abs( obj1.x - obj2.x )  local dY = math.abs( obj1.y - obj2.y )  local distance = math.sqrt( dX ^ 2 + dY ^ 2 )

Rob

 i need the distance in the physics world. because i am using zoom in-out camera functions so pixel-based distance depends on scaling. am i wrong?

and @Rob thanks for Pythagorean Theorem :slight_smile:

According to the docs:  https://docs.coronalabs.com/guide/physics/physicsSetup/index.html#physics.setscale

The default scale is 30 pixels per meter. You can divide your distance by 30 to get meters.

Rob

This is the Pythagorean Theorem caluculation from Algebra. See:

http://www.mathopenref.com/coorddist.html

Converted to Lua:

local dX = math.abs( obj1.x - obj2.x )  local dY = math.abs( obj1.y - obj2.y )  local distance = math.sqrt( dX ^ 2 + dY ^ 2 )

Rob

 i need the distance in the physics world. because i am using zoom in-out camera functions so pixel-based distance depends on scaling. am i wrong?

and @Rob thanks for Pythagorean Theorem :slight_smile:

According to the docs:  https://docs.coronalabs.com/guide/physics/physicsSetup/index.html#physics.setscale

The default scale is 30 pixels per meter. You can divide your distance by 30 to get meters.

Rob