Created
November 11, 2019 15:29
-
-
Save rbnpercy/f5e503de975a926e9ad6f11c3e5a9b29 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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