Stormworks: Build and Rescue

Stormworks: Build and Rescue

Frag2000 Oct 7, 2020 @ 11:54am
How to calculate distance between two coordinate?
Hi guys,

as you know there are no scale on the map. So having an idea of distance is not that obvious. I guess one of you know how to calculate the distance between two coordinate points?

Example:

What is the distance between x=0,y=0 and x=1000, y=0
< >
Showing 1-7 of 7 comments
GrumpyOldMan Oct 7, 2020 @ 12:00pm 
From two points, A (0,0) and B (1000,0):

xDist = bX - aX
yDist = bY - aY
sqrt((xDist ^ 2) + (yDist ^ 2))
Last edited by GrumpyOldMan; Oct 7, 2020 @ 12:01pm
Frag2000 Oct 7, 2020 @ 12:45pm 
Originally posted by GrumpyOldMan:
From two points, A (0,0) and B (1000,0):

xDist = bX - aX
yDist = bY - aY
sqrt((xDist ^ 2) + (yDist ^ 2))

Thanks for the anwer GrumpyOldman but I meant in Stormworks. I know the formula you gave, which is right ... but this would give us the distance in pixel.

I want to know in KM in the game world. Is a pixel 1 meters, 5 meters or 50 meters.

Briefly, what would be the distance in meter between two points.

What would be the distance in meter of (0,0) to (0,1)?
Last edited by Frag2000; Oct 7, 2020 @ 12:52pm
XLjedi Oct 7, 2020 @ 1:18pm 
In stormworks... given two points (x,y) and (a,b)

((a-x)^2+(b-y)^2)^(1/2)/1000

The formula above would give distance in km because I divided by 1000
otherwise, it's distance in meters. The map in stormworks states x,y in terms of meters, not pixels.

In my application, (a,b) are the x,y points provided by a GPS unit (my current position) and (x,y) are just any x,y points I want to measure my distance from.

However, in fairness to Grumpy... it's the same exact formula he provided. I just copy/pasted it directly from the formula input in my logic editor.
Last edited by XLjedi; Oct 7, 2020 @ 1:27pm
Frag2000 Oct 7, 2020 @ 2:16pm 
Originally posted by XLjedi:
In stormworks... given two points (x,y) and (a,b)

((a-x)^2+(b-y)^2)^(1/2)/1000

The formula above would give distance in km because I divided by 1000
otherwise, it's distance in meters. The map in stormworks states x,y in terms of meters, not pixels.

In my application, (a,b) are the x,y points provided by a GPS unit (my current position) and (x,y) are just any x,y points I want to measure my distance from.

However, in fairness to Grumpy... it's the same exact formula he provided. I just copy/pasted it directly from the formula input in my logic editor.

Yeah thanks guys I do get it now. So the unit is in meters.

Thanks a lot. That clarified the ole thing. :)
Randox Oct 8, 2020 @ 2:54am 
You can also use the len(x,y) function. If you have the GPS co-ordinates (x,y) and (a,b) the formula would be len(x-a, y-b). It's the same thing as given above, but saves some writing and is easier to read.
XLjedi Oct 8, 2020 @ 7:02am 
Originally posted by Randox:
You can also use the len(x,y) function. If you have the GPS co-ordinates (x,y) and (a,b) the formula would be len(x-a, y-b). It's the same thing as given above, but saves some writing and is easier to read.

I don't *think* that shortcut ports to LUA. So I would stick to the pure math operators.
Randox Oct 8, 2020 @ 8:23am 
Originally posted by XLjedi:
Originally posted by Randox:
You can also use the len(x,y) function. If you have the GPS co-ordinates (x,y) and (a,b) the formula would be len(x-a, y-b). It's the same thing as given above, but saves some writing and is easier to read.

I don't *think* that shortcut ports to LUA. So I would stick to the pure math operators.
Oops, good point. Not sure it does either.
< >
Showing 1-7 of 7 comments
Per page: 1530 50

Date Posted: Oct 7, 2020 @ 11:54am
Posts: 7