vector3.py

Created by asness

Created on February 28, 2019

1005 Bytes


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

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.