Skip to content

Instantly share code, notes, and snippets.

@rbnpercy
Created November 11, 2019 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbnpercy/f5e503de975a926e9ad6f11c3e5a9b29 to your computer and use it in GitHub Desktop.
Save rbnpercy/f5e503de975a926e9ad6f11c3e5a9b29 to your computer and use it in GitHub Desktop.
require "json"
text = File.read("1.json")
jobj = JSON.parse(text)
coordinates = jobj["coordinates"].as_a
len = coordinates.size
x = y = z = 0
coordinates.each do |coord|
x += coord["x"].as_f
y += coord["y"].as_f
z += coord["z"].as_f
end
p x / len
p y / len
p z / len
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment