Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- from FreeCAD import Vector
- import Part
- def calcRadCenter(v1,radius,v2,cw):
- '''
- calculates centerpoint for arc move that uses only radius value
- and is missing I,J,K coords.v1 = start pt of arc,v2 =end pt of arc
- '''
- chord = v2.sub(v1)
- l = Part.makeLine((v1.x,v1.y,v1.z),(v2.x,v2.y,v2.z))
- sagitta = radius-math.sqrt(math.pow(radius,2)- math.pow(l.Length/2.0,2))
- if cw:
- perp = chord.cross(Vector(0,0,1))
- else:
- perp = chord.cross(Vector(0,0,-1))
- startpoint = v1.add(chord.multiply(0.5))
- perp.normalize()
- centerpt = startpoint.add(perp.multiply(radius-sagitta))
- return centerpt
- def calcIJK(v1,centerpt):
- '''
- return relative IJK values from a previous point (vector) to the center of an arc
- (also a vector)
- '''
- return centerpt.sub(v1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement