Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- assuming your mobile computer previous coordinates were 99 120 100
- local previous_X, previous_Y, previous_Z = 99, 120, 100
- -- assuming your mobile computer current coordinates are 111 112 113
- local list_of_satellites = {
- {x=22, y=55, z=77, distance=((111-22)^2+(112-55)^2+(113-77)^2)^0.5}, -- correct satellite
- {x=35, y=99, z=42, distance=((111-35)^2+(112-99)^2+(113-42)^2)^0.5}, -- correct satellite
- {x=44, y=44, z=44, distance=((111-94)^2+(112-94)^2+(113-94)^2)^0.5}, -- incorrect satellite
- {x=10, y=88, z=70, distance=((111-10)^2+(112-88)^2+(113-70)^2)^0.5}, -- correct satellite
- {x=54, y=54, z=54, distance=((111-64)^2+(112-64)^2+(113-64)^2)^0.5}, -- incorrect satellite
- {x=91, y=33, z=15, distance=((111-91)^2+(112-33)^2+(113-15)^2)^0.5}, -- correct satellite
- }
- local X, Y, Z, list_of_incorrect_sat_indices = trilateration(list_of_satellites, previous_X, previous_Y, previous_Z)
- if X then
- print(X, Y, Z)
- if #list_of_incorrect_sat_indices > 0 then
- print("Satellites at the following indices are incorrect: "..table.concat(list_of_incorrect_sat_indices, ","))
- end
- else
- print"Not enough satellites"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement