On Sat, Jul 29, 2017 at 8:53 AM, Luke Kenneth Casson Leighton <lkcl@lkcl.net
wrote:
http://hands.com/~lkcl/foldable3dsandwich200/belts.py
ok, i could use some algorithm help, here, if anyone's interested. the key function is add_bearing in class Belt.
I don't really speak python, but I'm happy to put my two cents in.
You've got three of the four cases defined, but to start with I only looked at the simple one (invert==0, oldinvert==0) which you seem to think is solved. Unless I'm missing something, it's not really solved at all -- it looks like it completely ignores any difference in radius when figuring the contact angles. And I think when you fix that, the hard cases will mostly explain themselves (you'll basically negate the radius in that calculation, and maybe also add/subtract the belt thickness).
So, given the old bearing has radius R1 and the new bearing has radius R2, separated horizontally (or at any other angle) by a distance D, we can find the deviation from horizontal (or in the general case, the deviation from the angle connecting their centers): arcsin((R1-R2)/D)
And of course, negate that if they're both inverted (rather than both noninverted). (Not entirely clear on your sign convention, so this may be exactly backwards, but you can figure that out faster than I could puzzle through it.)
And if you're crossing over, with belt thickness T, that should just become arcsin((R1+R2+T)/D) (again, this is going from noninverted to inverted -- negate for inverted to noninverted, or maybe the opposite.) But of course in this case, you leave the first bearing at one angle, and contact the second bearing at the opposite angle; if you actually redefine R2=-(R2+T), this takes care of itself, so you might not need all the cases. (Though the part where you wrap the arc around the old bearing will need to be careful about clockwise/counterclockwise.)
Hope that helps.
Benson Mitchell