Angle between CA-CB of knob and CA(h1)-CA(h2). Returns None if knob is GLY.
330208
def packing_angle(self):
        
        try:
            knob_vector = self.knob_residue['CB'] - self.knob_residue['CA']
        # exception for GLY residues (with no CB atom).
        except KeyError:
            return None
        hole_vector = self.hole_residues[2]['CA'] - self.hole_residues[1]['CA']
        return angle_between_vectors(knob_vector, hole_vector)
474903
public static int getTriangleWindingRule( Coordinate A, Coordinate B, Coordinate C ) {
        double[] rBA = {B.x - A.x, B.y - A.y, B.z - A.z};
        double[] rCA = {C.x - A.x, C.y - A.y, C.z - A.z};

        double[] crossProduct = {//
                /*    */rBA[1] * rCA[2] - rBA[2] * rCA[1], //
                -1 * (rBA[0] * rCA[2] - rBA[2] * rCA[0]), //
                rBA[0] * rCA[1] - rBA[1] * rCA[0] //
        };

        return crossProduct[2] > 0 ? 1 : -1;
    }
749688
def ca_main_axis(self):
        """"""
        try:
            ca_ind = self.dim_types.index(DT.CA_SUBVAR)
            return 1 - ca_ind
        except ValueError:
            return None
697441
def abs_angle_diff(v_i, v_j):
    
    # compute angle distance
    dot_prod = min(max(v_i.dot(v_j), -1), 1)
    angle_diff = np.arccos(dot_prod)
    return np.abs(angle_diff)
106408
def _get_v_angle_guess(self, case):
        
        v_angle = array([bus.v_angle * (pi / 180.0)
                         for bus in case.connected_buses])
        return v_angle
884685
function angleDiff(angle1, angle2){
        var deltaAngle = angle1-angle2;
        while (deltaAngle < -Math.PI) deltaAngle += (2*Math.PI);
        while (deltaAngle > Math.PI) deltaAngle -= (2*Math.PI);
        return Math.abs(deltaAngle);
    }
337201
function getVerticalFOV(hFov, aspectRatio) {
  var hFovRad = hFov * Math.PI / 180;
  var vFovRad = 2 * Math.atan(Math.tan(hFovRad / 2) / aspectRatio);
  return vFovRad * 180 / Math.PI;
}
1355866
def angle(self, v):
        ''''''
        return acos((self * v) / (self.length() * v.length()))
80057
def horizontal_angle(C, P):
        
        S = Point(P - C).unit                   # unit vector 'C' -> 'P'
        alfa = math.asin(abs(S.y))              # absolute angle from horizontal
        if S.x < 0:                             # make arcsin result unique
            if S.y <= 0:                        # bottom-left
                alfa = -(math.pi - alfa)
            else:                               # top-left
                alfa = math.pi - alfa
        else:
            if S.y >= 0:                        # top-right
                pass
            else:                               # bottom-right
                alfa = - alfa
        return alfa
787346
def density_angle(rho0: Density, rho1: Density) -> bk.BKTensor:
    """"""
    return fubini_study_angle(rho0.vec, rho1.vec)
351987
def from_axis_angle(self, axis, angle):
        ''''''
        ux = axis.x
        uy = axis.y
        uz = axis.z
        ct = cos(angle)
        st = sin(angle)
        self.a.x = ct + (1-ct) * ux**2
        self.a.y = ux*uy*(1-ct) - uz*st
        self.a.z = ux*uz*(1-ct) + uy*st
        self.b.x = uy*ux*(1-ct) + uz*st
        self.b.y = ct + (1-ct) * uy**2
        self.b.z = uy*uz*(1-ct) - ux*st
        self.c.x = uz*ux*(1-ct) - uy*st
        self.c.y = uz*uy*(1-ct) + ux*st
        self.c.z = ct + (1-ct) * uz**2
235257
def vecangle(v1, v2, deg=True):
    
    if np.array_equal(v1, v2):
        return 0.0
    dm = np.dot(v1, v2)
    cm = np.linalg.norm(v1) * np.linalg.norm(v2)
    angle = np.arccos(round(dm / cm, 10))  # Round here to prevent floating point errors
    return np.degrees([angle, ])[0] if deg else angle
1147710
def c2s(self, p=None):
        """"""
        if not p:
            p = [0, 0]

        return p[0] - self.canvasx(self.cx1), p[1] - self.canvasy(self.cy2)
601829
function calcScreenAngle (deviceAngle) {
  // When device rotates 90deg clockwise, screen compensates by rotating 90deg
  // counterclockwise, then screen angle becomes 270deg.
  let angle = -deviceAngle % 360
  if (angle < 0) {
    angle = 360 + angle
  }
  angle = Math.floor((angle + 45) / 90) * 90
  angle %= 360
  return angle
}
91086
def bend_rounded_Ito(Di, angle, Re, rc=None, bend_diameters=None, 
                     roughness=0.0):
    '''
    '''
    if not rc:
        if bend_diameters is None:
            bend_diameters = 5.0
        rc = Di*bend_diameters
    
    radius_ratio = rc/Di
    angle_rad = radians(angle)
    De2 = Re*(Di/rc)**2.0
    if rc > 50.0*Di:
        alpha = 1.0
    else:
        # Alpha is up to 6, as ratio gets higher, can go down to 1
        alpha_45 = 1.0 + 5.13*(Di/rc)**1.47
        alpha_90 = 0.95 + 4.42*(Di/rc)**1.96 if rc/Di < 9.85 else 1.0
        alpha_180 = 1.0 + 5.06*(Di/rc)**4.52
        alpha = interp(angle, _Ito_angles, [alpha_45, alpha_90, alpha_180])
    
    if De2 <= 360.0:
        fc = friction_factor_curved(Re=Re, Di=Di, Dc=2.0*rc,
                                    roughness=roughness,
                                    Rec_method='Srinivasan', 
                                    laminar_method='White',
                                    turbulent_method='Srinivasan turbulent')
        K = 0.0175*alpha*fc*angle*rc/Di
    else:
        K = 0.00431*alpha*angle*Re**-0.17*(rc/Di)**0.84
    return K
332477
def click_estimate_curvature():
    

    c1 = _pylab.ginput()
    if len(c1)==0:
        return None

    c2 = _pylab.ginput()
    if len(c2)==0:
        return None

    return 2*(c2[0][1]-c1[0][1])/(c2[0][0]-c1[0][0])**2
1185493
def PC_AC1_calc(P, TOP, POP):
    
    try:
        result = 0
        classes = list(P.keys())
        for i in classes:
            pi = ((P[i] + TOP[i]) / (2 * POP[i]))
            result += pi * (1 - pi)
        result = result / (len(classes) - 1)
        return result
    except Exception:
        return "None"