Advertisement
danfalck

Untitled

Sep 24th, 2011
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. def calc_center(v1,bulge,v2):
  2.     '''
  3.    calculates center of arc- this one works
  4.    '''
  5.     chord = numpy.subtract(v2,v1)
  6.     chord_length= numpy.linalg.norm(chord)
  7.     sagitta = (bulge*chord_length)/2.0
  8.     inc_angle = numpy.arctan(bulge)*4.0
  9.     radius = (chord_length/2.0)/numpy.sin(inc_angle/2.0)
  10.     if bulge >= 0:
  11.         perp = (numpy.cross(chord,(0,0,-1)))
  12.     else:
  13.         perp = (numpy.cross(chord,(0,0,1)))
  14.     chord_mid_pt = numpy.add(numpy.multiply(chord,(.5,.5,.5)),v1)
  15.     unit_vec = perp/ numpy.linalg.norm(perp)
  16.     arc_center = numpy.add(numpy.multiply((radius-sagitta),unit_vec),chord_mid_pt)
  17.     return arc_center
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement