Calculates the pole of a polar plane for
        a given conic section.
171523
def pole(conic, plane):
        
        v = dot(N.linalg.inv(conic),plane)
        return v[:-1]/v[-1]
1283986
private void calcPrincipalRotationVector() {
		Rotation rotation = rotationGroup.getRotation(0); // the rotation around the principal axis is the first rotation
		AxisAngle4d axisAngle = rotation.getAxisAngle();
		principalRotationVector = new Vector3d(axisAngle.x, axisAngle.y, axisAngle.z);
	}
1016985
function(theta) {
            while (theta < 0) {
                theta += mathUtils.TWO_PI;
            }
            return this.sinLUT[((theta * this.rad2deg) + this.quadrant) % this.period];
        }
316793
def convert(lat, lon):
    """"""

    x = numpy.cos(lon) * numpy.cos(lat)
    y = numpy.sin(lon) * numpy.cos(lat)
    z = numpy.sin(lat)

    # Invariable plane: values in arcseconds.
    epsilon = 5713.86
    omega = 387390.8

    coseps = numpy.cos(epsilon * secrad)
    sineps = numpy.sin(epsilon * secrad)
    cosom = numpy.cos(omega * secrad)
    sinom = numpy.sin(omega * secrad)

    xi = x * cosom + y * sinom
    yi = coseps * (-sinom * x + cosom * y) + sineps * z
    zi = - sineps * (-sinom * x + cosom * y) + coseps * z

    lat = numpy.arcsin(zi)
    lon = numpy.arctan2(yi, xi)
    return (lat, lon)
93326
public boolean estimatePlaneAtInfinity( DMatrixRMaj P2 , Vector3D_F64 v ) {
		PerspectiveOps.projectionSplit(P2,Q2,q2);

		// inv(K2)*(Q2*K1 + q2*v')
		CommonOps_DDF3.mult(K2_inv,q2,t2);
		CommonOps_DDF3.mult(K2_inv,Q2,tmpA);
		CommonOps_DDF3.mult(tmpA,K1,tmpB);

		// Find the rotation matrix R*t2 = [||t2||,0,0]^T
		computeRotation(t2,RR);

		// Compute W
		CommonOps_DDF3.mult(RR,tmpB,W);

		// Compute v, the plane at infinity
		// v = (w2 cross w3 / ||w3|| - w1 ) / ||t2||
		w2.set(W.a21,W.a22,W.a23);
		w3.set(W.a31,W.a32,W.a33);
		double n3 = w3.norm();
		v.cross(w2,w3); // approximation here, w2 and w3 might not be orthogonal
		v.divideIP(n3);
		v.x -= W.a11;
		v.y -= W.a12;
		v.z -= W.a13;
		v.divideIP(t2.a1);

		// really just a sanity check for bad input
		return !(UtilEjml.isUncountable(v.x) || UtilEjml.isUncountable(v.y) || UtilEjml.isUncountable(v.z));
	}
1361975
static double computeSignedArea(List<IGeoPoint> path, double radius) {
        int size = path.size();
        if (size < 3) { return 0; }
        double total = 0;
        IGeoPoint prev = path.get(size - 1);
        double prevTanLat = tan((PI / 2 - toRadians(prev.getLatitude())) / 2);
        double prevLng = toRadians(prev.getLongitude());
        // For each edge, accumulate the signed area of the triangle formed by the North Pole
        // and that edge ("polar triangle").
        for (IGeoPoint point : path) {
            double tanLat = tan((PI / 2 - toRadians(point.getLatitude())) / 2);
            double lng = toRadians(point.getLongitude());
            total += polarTriangleArea(tanLat, lng, prevTanLat, prevLng);
            prevTanLat = tanLat;
            prevLng = lng;
        }
        return total * (radius * radius);
    }
703170
def calc_2d_ellipse_properties(cov,nstd=2):
    """"""
    def eigsorted(cov):
        vals, vecs = np.linalg.eigh(cov)
        order = vals.argsort()[::-1]
        return vals[order], vecs[:,order]

    vals, vecs = eigsorted(cov)
    width, height = 2 * nstd * np.sqrt(vals[:2])
    normal = vecs[:,2] if vecs[2,2] > 0 else -vecs[:,2]
    d = np.cross(normal, (0, 0, 1))
    M = rotation_matrix(d)
    x_trans = np.dot(M,(1,0,0))
    cos_val = np.dot(vecs[:,0],x_trans)/np.linalg.norm(vecs[:,0])/np.linalg.norm(x_trans)
    theta = np.degrees(np.arccos(np.clip(cos_val, -1, 1))) # if you really want the angle
    return { 'width': width, 'height': height, 'angle': theta }, normal
1151086
def ellipse(self, x, y, width, height, edges = None):
        """"""
        # the automatic edge case is somewhat arbitrary
        steps = edges or max((32, width, height)) / 2

        angle = 0
        step = math.pi * 2 / steps
        points = []
        while angle < math.pi * 2:
            points.append((width / 2.0 * math.cos(angle),
                           height / 2.0 * math.sin(angle)))
            angle += step

        min_x = min((point[0] for point in points))
        min_y = min((point[1] for point in points))

        self.move_to(points[0][0] - min_x + x, points[0][1] - min_y + y)
        for p_x, p_y in points:
            self.line_to(p_x - min_x + x, p_y - min_y + y)
        self.line_to(points[0][0] - min_x + x, points[0][1] - min_y + y)
1078447
def projection(self, **kwargs):
        
        viewpoint = kwargs.pop('viewpoint', None)
        if viewpoint is None:
            ndim = self.shape[0]-1
            viewpoint = N.zeros(ndim)
        plane = self.polar_plane(viewpoint)
        return self.slice(plane, **kwargs)
567030
def b(self):
        '''
        

        '''
        b = Point(self.center)

        if self.xAxisIsMinor:
            b.x += self.minorRadius
        else:
            b.y += self.minorRadius
        return b
279919
def _polevl(x, coefs, N):
    
    ans = 0
    power = len(coefs) - 1
    for coef in coefs:
        try:
            ans += coef * x**power
        except OverflowError:
            pass
        power -= 1
    return ans
198501
def parse_latitude(latitude, hemisphere):
    
    latitude = int(latitude[:2]) + float(latitude[2:]) / 60
    if hemisphere == 'S':
        latitude = -latitude
    elif not hemisphere == 'N':
        raise ValueError('Incorrect North/South value %r' % hemisphere)
    return latitude
737173
function lnpost(theta, x, y) {
  var lp = lnprior(theta);
  if (!isFinite(lp)) {
    return -Infinity;
  }
  return lp + lnlike(theta, x, y);
}
460158
function polar(inData, outData, x0, y0, width, height, callback) {
    /* Sets image data based on a polar coordinates filter.
     * The given callback is a function(distance, angle) that returns new [distance, angle].
     */
    x0 = width / 2 + (x0 || 0);
    y0 = height / 2 + (y0 || 0);
    var y1, x1, x, y, d, a, v;
    for (y1 = 0; y1 < height; y1 += 1) {
        for (x1 = 0; x1 < width; x1 += 1) {
            x = x1 - x0;
            y = y1 - y0;
            d = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
            a = Math.atan2(y, x);
            v = callback(d, a);
            d = v[0];
            a = v[1];
            setPixel(outData, x1 + y1 * width, getPixel(inData,
                Math.round(x0 + Math.cos(a) * d) +
                Math.round(y0 + Math.sin(a) * d) * width
            ));
        }
    }
}
1344681
def AuxPlane(s1, d1, r1):
    
    r2d = 180 / np.pi

    z = (s1 + 90) / r2d
    z2 = d1 / r2d
    z3 = r1 / r2d
    # slick vector in plane 1
    sl1 = -np.cos(z3) * np.cos(z) - np.sin(z3) * np.sin(z) * np.cos(z2)
    sl2 = np.cos(z3) * np.sin(z) - np.sin(z3) * np.cos(z) * np.cos(z2)
    sl3 = np.sin(z3) * np.sin(z2)
    (strike, dip) = StrikeDip(sl2, sl1, sl3)

    n1 = np.sin(z) * np.sin(z2)  # normal vector to plane 1
    n2 = np.cos(z) * np.sin(z2)
    h1 = -sl2  # strike vector of plane 2
    h2 = sl1
    # note h3=0 always so we leave it out
    # n3 = np.cos(z2)

    z = h1 * n1 + h2 * n2
    z = z / np.sqrt(h1 * h1 + h2 * h2)
    z = np.arccos(z)
    rake = 0
    if sl3 > 0:
        rake = z * r2d
    if sl3 <= 0:
        rake = -z * r2d
    return (strike, dip, rake)
1137344
def cylindrical(cls, mag, theta, z=0):
        ''''''
        return cls(
            mag * math.cos(theta),  # X
            mag * math.sin(theta),  # Y
            z  # Z
        )
1192029
def calcAspectRatioFromCorners(corners, in_plane=False):
    '''
    
    '''

    q = corners
    l0 = [q[0, 0], q[0, 1], q[1, 0], q[1, 1]]
    l1 = [q[0, 0], q[0, 1], q[-1, 0], q[-1, 1]]

    l2 = [q[2, 0], q[2, 1], q[3, 0], q[3, 1]]
    l3 = [q[2, 0], q[2, 1], q[1, 0], q[1, 1]]

    a1 = line.length(l0) / line.length(l1)
    a2 = line.length(l2) / line.length(l3)

    if in_plane:
        # take aspect ration from more rectangular corner
        if (abs(0.5 * np.pi - abs(line.angle2(l0, l1)))
                < abs(0.5 * np.pi - abs(line.angle2(l2, l3)))):
            return a1
        else:
            return a2

    return 0.5 * (a1 + a2)