python: calculate steps for dreamcatcher -


i stuck trying calculate dreamcatcher , inner circles. have outer circle given radius x , need calculate perimeter. have calculate magic value how wide every bow (in image stuff numbers) should , should result bows not finish @ start point overlapp half bow first.

how done

here tried far:

import math  # in cm rad = 5.0  perimeter = round(rad * 2.0 * math.pi, 2) print "perimeter == %f" % perimeter  #bow = "?" incvalue = 0.00001 start = incvalue end = perimeter while start < end / 10:   tmp = start * 10   while tmp < perimeter:     tmp += start    if tmp - perimeter == start / 2:     print "bow %s" % str(tmp)    start += incvalue  print "done" 

but not able find value fits constraints.

i think can value want with

bow_length = perimeter / (desired_number_of_full_bows + 0.5) 

but if you're interested in getting approximation system working, think line causing problems:

if tmp - perimeter == start / 2: 

floating point numbers compare equal 1 another, conventional instead check close together. might instead do:

if abs((tmp - perimeter) - (start / 2)) < epsilon: 

... epsilon represents largest possible "wiggle room" between 2 numbers willing accept. 0.0001, although experiment larger or smaller values see works best.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -