def wingpos(self): """ Calculates wing position according to given mechanism motion and wing definition """ # hand over interface hinge positions from mechanism self.wpos.front.A = self.mpos.front.A self.wpos.back.A = self.mpos.back.A self.wpos.front.O = self.mpos.front.O self.wpos.back.O = self.mpos.back.O for sdef, spos, A, B, O in zip([self.wdef.front, self.wdef.back],[self.wpos.front,self.wpos.back], [self.mpos.front.A, self.mpos.back.A],[self.mpos.front.B, self.mpos.back.B],[self.mpos.front.O, self.mpos.back.O]): OA = np.mean(np.linalg.norm((A[0:2]-O[0:2]), axis=0)) OB = np.mean(np.linalg.norm((B[0:2]-O[0:2]), axis=0)) Cx = O[0] + (O[0]-B[0]) / OB * sdef.OC Cy = O[1] + (O[1]-B[1]) / OB * sdef.OC Cz = O[2] spos.C = np.array([Cx, Cy, Cz]) E1 , E2 = triangle(A,spos.C,sdef.EC,sdef.AE,np.linalg.norm(spos.C[0:2]-A[0:2],axis=0)) spos.E = E1 D1, D2 = triangle(spos.E,spos.C,sdef.CD,sdef.ED,sdef.EC) theta = np.radians(self.sweep) D = [] for c, e, d in zip(spos.C.T, spos.E.T, D1.T): axis = c-e m = rot_axis(axis, theta) D.append(np.dot(m, d)) spos.D = np.vstack(D).T
def execute(self): """ do your calculations here """ for ldef, lpos, phi in zip([self.mdef.front, self.mdef.back],[self.mpos.front,self.mpos.back], [np.zeros(len(self.theta)), self.phi]): # Position of origin hinge O_x = np.zeros(len(self.theta)) O_y = np.zeros(len(self.theta)) O_z = np.ones(len(self.theta)) * ldef.z lpos.O = np.array([O_x, O_y, O_z]) # Position of outer gear mount Q_x = ldef.G[0] + ldef.Ro * np.cos(self.theta - phi) Q_y = ldef.G[1] + ldef.Ro * np.sin(self.theta - phi) Q_z = ldef.z * np.ones(len(self.theta)) lpos.Q = np.array([Q_x, Q_y, Q_z]) # Position of inner gear mount P_x = ldef.G[0] + ldef.Ri * np.cos(self.theta + ldef.theta_del - phi) P_y = ldef.G[1] + ldef.Ri * np.sin(self.theta + ldef.theta_del - phi) P_z = ldef.z * np.ones(len(self.theta)) lpos.P = np.array([P_x, P_y, P_z]) # Position of point A lpos.A,dum = triangle(lpos.P,lpos.O,ldef.AO,ldef.PA,np.linalg.norm(lpos.P[0:2],axis=0)) # Position of point B dum,lpos.B = triangle(lpos.Q,lpos.O,ldef.BO,ldef.QB,np.linalg.norm(lpos.Q[0:2],axis=0))