from vector1 import r from vector2 import O, va, vs, vm, vdist, dp, cp, stp '''revised 190227''' '''vector operations, continued''' def pldist(a, b, c): '''distance from point a to a line containing b and c''' ba = vdist(a, b) bc = vdist(b, c) return r(cp(ba, bc)) / r(bc) def lldist(p1, d1, p2, d2): '''Distance between two skew lines L1 and L2. L_i contains point p_i and its direction is d_i: i.e. r_i(t_i) == p_i + t_i * d_i''' return stp(vdist(p1, p2), d1, d2) / r(cp(d1, d2)) def fcsys(rs, Fs, PMs=[O]): '''Force-couple system given forces and pure moments''' R = vs(Fs) Ms = [cp(r, F) for (r, F) in zip(rs, Fs)] MR = va(vs(Ms), vs(PMs)) return R, MR def wr(R, M): '''Given a force-couple system, find the equivalent wrench's pitch p and its closest point to origin R0. The pitch axis line can be written as x(t) == R0 + t * R''' p = dp(R, M) / r(R)**2 R0 = vm(cp(R, M), 1/r(R)**2) return p, R0