#!/usr/bin/env ruby # encoding: utf-8 require 'gss' require 'optparse' require 'csv' options = {} opts = OptionParser.new opts.banner = "Generate points with uniform distribution on the sphere." opts.on("-c", "--cartesian", "Cartesian coordinate."){|v| options[:cartesian] = true } opts.on_tail("-h", "--help", "Show this message."){|v| print opts.help exit } opts.on_tail("-v", "--version", "Show version."){|v| puts "v#{GSS::VERSION}" exit } opts.parse! r = ARGV.shift.to_f n = ARGV.shift.to_i gss = GSS::GSS.new points = gss.generate(r, n) points.each do |p| if options[:cartesian] coord = p.to_cartesian print coord.to_csv else print [p.r, p.theta, p.phi].to_csv end end