Skip to content

Instantly share code, notes, and snippets.

@spilliams
Created June 27, 2014 17:35
Show Gist options
  • Save spilliams/c3785dd5a157059bef70 to your computer and use it in GitHub Desktop.
Save spilliams/c3785dd5a157059bef70 to your computer and use it in GitHub Desktop.
spits out xy coordinates of points on a circle given its properties
# simple ruby script to spit out x,y coords of points on a circle given properties
require "highline/import"
radius = Float(ask "radius? ")
originX = Float(ask "X coord of center? ")
originY = Float(ask "Y coord of center? ")
minTheta = Float(ask "minTheta (deg)? ") * Math::PI/180
maxTheta = Float(ask "maxTheta (deg)? ") * Math::PI/180
dTheta = Float(ask "dTheta (rad)? ") * Math::PI/180
theta = minTheta
while theta < maxTheta
#wrt center of circle
x = radius*Math.cos(theta)
y = radius*Math.sin(theta)
#wrt outside coords
x += originX
y += originY
puts "#{x.round} #{y.round}"
theta += dTheta
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment