aboutsummaryrefslogtreecommitdiff
path: root/logcircle.rb
blob: 95d57aceaa3c228dbac844eea6cfdaeff8b52b50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env ruby

Maths = Math

Intervals = ARGV.shift&.to_i || 2
Radius = ARGV.shift&.to_i || 25
Decimals = ARGV.shift&.to_i || 3

Scale = Maths::PI * 2 / Intervals
Width = 1 + Maths.log10(Radius).to_i + 1 + 1 + Decimals

def a_tick(mantissa, exponent)
  tick = mantissa * (10 ** exponent)
  loc = Scale * (exponent + Maths.log10(mantissa))
  x = Radius * Maths.cos(loc)
  y = Radius * Maths.sin(loc)
  puts "%#{Intervals + 1}d: (%4.2fr) %#{Width}.#{Decimals}f %#{Width}.#{Decimals}f" % [tick, loc, x, y]
end

puts "Max #{10 ** Intervals} (#{Intervals} intervals), radius #{Radius}, #{Decimals} decimals"

Intervals.times do |exponent|
  (1..9).each do |mantissa|
    a_tick(mantissa, exponent)
  end
end

a_tick(1, Intervals)