Пример #1
0
def arc12_pt3(xyz1, xyz2, xyz3):
    '''
    Three points should be on same circle.
    '''

    vec1 = x1, y1, z1 = xyz1
    vec2 = x2, y2, z2 = xyz2
    vec3 = x3, y3, z3 = xyz3

    unit_nvec = normal_vector(vec1, vec2, normalize=True)
    cp1 = np.dot(unit_nvec, np.cross(vec1, vec3))
    cp2 = np.dot(unit_nvec, np.cross(vec2, vec3))

    if feq(cp1,0):
        if feq(cp2,0):
            raise ValueError("cp1 and cp2 are both zero")
        elif flt(cp2,0):
            return 'pt1'
        elif fgt(cp2,0):
            return 'out'

    elif flt(cp1,0):
        return 'out'

    elif fgt(cp1,0):
        if feq(cp2,0):
            return 'pt2'
        elif flt(cp2,0):
            return 'between'
        elif fgt(cp2,0):
            return 'out'
Пример #2
0
def xyz2xyp(X, Y, Z, R=1):
    assert feq(sqrt(X*X + Y*Y + Z*Z),R), 'The (x,y,z) (%s,%s,%s) is not on the sphere.'%(X,Y,Z)

    a = R/sqrt(3)
    at1, at2 = a*tan(-pi/4), a*tan(pi/4)

    xyp_dict = dict()


    if fgt(X,0):
        x, y = a*(Y/X), a*(Z/X)
        if flge(at1,x,at2) and flge(at1,y,at2):
            xyp_dict[1] = (x,y)

    elif flt(X,0):
        x, y = a*(Y/X), -a*(Z/X)
        if flge(at1,x,at2) and flge(at1,y,at2):
            xyp_dict[3] = (x,y)


    if fgt(Y,0):
        x, y = -a*(X/Y), a*(Z/Y)
        if flge(at1,x,at2) and flge(at1,y,at2):
            xyp_dict[2] = (x,y)

    elif flt(Y,0):
        x, y = -a*(X/Y), -a*(Z/Y)
        if flge(at1,x,at2) and flge(at1,y,at2):
            xyp_dict[4] = (x,y)


    if flt(Z,0):
        x, y = -a*(Y/Z), -a*(X/Z)
        if flge(at1,x,at2) and flge(at1,y,at2):
            xyp_dict[5] = (x,y)

    elif fgt(Z,0):
        x, y = a*(Y/Z), -a*(X/Z)
        if flge(at1,x,at2) and flge(at1,y,at2):
            xyp_dict[6] = (x,y)


    return xyp_dict
Пример #3
0
def plane12_pt3(xyz1, xyz2, xyz3):
    '''
    plane generated by xyz1 and xyz2
    left if xyz3 is in normal vector direction
    '''

    plane = plane_origin(xyz1, xyz2)
    #nvec = normal_vector(xyz1, xyz2)
    #print np.dot(plane,nvec)       # > 0 

    val = np.dot(plane, xyz3)

    if feq(val,0):
        return 'straight'
    elif flt(val,0):
        return 'right'
    elif fgt(val,0):
        return 'left'