1 posts
Posted 20 January 2015 - 09:48 PM
I'm kind of good at computercraft and know a bit of lua. I was wondering how I can use Gps (API) and Vector (API) on a
advanced pocket computer to make a tape measure (measure the distance between two points). I read on the GPS api
"there must be at least 4 computers used as gps hosts which will respond and allow trilateration". Can someone help me code a tape measure program with a simple gui? Maybe the program can have two modes (actual distance between two points) and another mode (it will tell you height difference, x axis difference, and y axis difference).
392 posts
Posted 21 January 2015 - 02:36 AM
Hi. First, you need to set up a GPS network. The easiest way (that I know of) is to use
this program. Once you have that. You then need to
specify a starting point. Once you have specified a starting point you can update your GPS position however often you want and display the distance between the two on the screen.
I won't code a GUI for you, but that is what you put in the actual program :)/>
Edited on 21 January 2015 - 01:36 AM
7083 posts
Location
Tasmania (AU)
Posted 21 January 2015 - 03:36 AM
Exactly which bits are you asking for help with?
The basic idea seems simple enough. Have a button on the APC which records your current position by performing a GPS lookup to one variable. Have another button which performs another lookup, and compares the location you're at to the previously recorded one.
For eg,
local function recordPos()
savedPos = vector.new(gps.locate())
end
local function comparePos()
distanceBetween = savedPos - vector.new(gps.locate())
print(distanceBetween:length())
end
Rig up some functions along these lines to run via
touchpoint buttons or something, and you're done.
8543 posts
Posted 21 January 2015 - 03:53 AM
I was going to post that Touchpoint didn't work on terminals (only monitors), but I decided to update it to work on terminals also. I'll update the OP of the Touchpoint topic with the details.
871 posts
Posted 21 January 2015 - 04:02 AM
someone should note, gps is not strictly required if you just want distance from A to B. Any two computers with modems will report the distance between them when recieving rednet messages. Of course, the program could be more convenient running on a tablet where you can just tap a button and walk out the distance to measure, but depending on your particular needs, it might be easier to just plonk a computer down.
Edited on 21 January 2015 - 03:03 AM