Created
June 27, 2014 17:35
-
-
Save spilliams/c3785dd5a157059bef70 to your computer and use it in GitHub Desktop.
spits out xy coordinates of points on a circle given its properties
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
# 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