続・円の交点を求める Brainstorm バージョン
Brainstrom上でプリミティブの交点にSphereをリアルタイムに配置できるようになったぉ
import math def xPoint(): # initial setting # C1 c1x = itemget("C1", "OBJ_DISPLACEMENT[0]") c1y = itemget("C1", "OBJ_DISPLACEMENT[1]") c1r = itemget("C1", "PRIM_SPHERE_FLATHOR") # C2 c2x = itemget("C2", "OBJ_DISPLACEMENT[0]") c2y = itemget("C2", "OBJ_DISPLACEMENT[1]") c2r = itemget("C2", "PRIM_SPHERE_FLATHOR") print 'C1 is x:%s y:%s r:%s'%(c1x, c1y, c1r) print 'C2 is x:%s y:%s r:%s'%(c2x, c2y, c2r) fA = math.sqrt((c2x - c1x)**2 + (c2y - c1y)**2) print 'fA is ',fA fPx = ((fA**2.0 + c1r**2.0 - c2r**2.0) / (fA*2.0)) print 'fPx is ',fPx fPy_parts = c1r*c1r - fPx*fPx print 'fPy_parts is ',fPy_parts fPy = math.sqrt( fPy_parts ) print 'fPy is ',fPy xP = c1x + fPx*(( c2x - c1x )/fA) + fPy*(( c2y -c1y )/fA) yP = c1y + fPx*(( c2y - c1y )/fA) - fPy*(( c2x -c1x )/fA) xM = c1x + fPx*(( c2x - c1x )/fA) - fPy*(( c2y -c1y )/fA) yM = c1y + fPx*(( c2y - c1y )/fA) + fPy*(( c2x -c1x )/fA) print 'x:', xP, 'y:', yP itemset("x_plus", "OBJ_DISPLACEMENT", vector(xP, yP, 0)) itemset("x_minus", "OBJ_DISPLACEMENT", vector(xM, yM, 0)) print 'import is OK'