returns the unit tangent of the segment at t.
337308
def unit_tangent(self, t=None):
        """"""
        assert self.end != self.start
        dseg = self.end - self.start
        return dseg/abs(dseg)
1024660
function findSquaredDistanceFromSegmentToPoint(segment, point) {
  findClosestPointOnSegmentToPoint(_segmentDistance_tmpVecA, segment, point);
  return vec3.squaredDistance(_segmentDistance_tmpVecA, point);
}
1147561
def segment_volume(seg):
    '''
    '''
    r0 = seg[0][COLS.R]
    r1 = seg[1][COLS.R]
    h = point_dist(seg[0], seg[1])
    return math.pi * h * ((r0 * r0) + (r0 * r1) + (r1 * r1)) / 3.0
542868
protected double getMeanExtension() {
		Vector3d dimension = rotationAxisAligner.getDimension();
		return (dimension.x+dimension.y+dimension.z)/3;
	}
1028789
def split(self, t):
        """"""
        bpoints1, bpoints2 = split_bezier(self.bpoints(), t)
        return CubicBezier(*bpoints1), CubicBezier(*bpoints2)
856425
def solve_t(self, Mt):
        
        if len(Mt.shape)==2:    _Mt = Mt[:, :, sp.newaxis]
        else:                   _Mt = Mt
        LMt = vei_CoR_veX(_Mt, R=self.Lr(), C=self.Lc())
        DLMt = self.D()[:, :, sp.newaxis] * LMt
        RV = vei_CoR_veX(DLMt, R=self.Lr().T, C=self.Lc().T)
        if len(Mt.shape)==2:    RV = RV[:, :, 0]
        return RV
221717
def bounds(self, thr=0):
        
        min_lat = float("inf")
        min_lon = float("inf")
        max_lat = -float("inf")
        max_lon = -float("inf")
        for segment in self.segments:
            milat, milon, malat, malon = segment.bounds(thr=thr)
            min_lat = min(milat, min_lat)
            min_lon = min(milon, min_lon)
            max_lat = max(malat, max_lat)
            max_lon = max(malon, max_lon)
        return min_lat, min_lon, max_lat, max_lon
1368983
public static double harmonicMean(DoubleTuple t)
    {
        double s =
            DoubleTupleFunctions.reduce(t, 0.0, (a, b) -> (a + (1.0 / b)));
        return t.getSize() / s;
    }
333605
public float getTangentY(int vertex) {
        if (!hasTangentsAndBitangents()) {
            throw new IllegalStateException("mesh has no bitangents");
        }
        
        checkVertexIndexBounds(vertex);
        
        return m_tangents.getFloat((vertex * 3 + 1) * SIZEOF_FLOAT);
    }
665545
def D(self):
        '''
        
        '''
        return Point(self.minX, self.maxY, self.origin.z)
505509
function(length, opt) {

            if (!this.isDifferentiable()) return null;

            var t = this.tAtLength(length, opt);

            return this.tangentAtT(t);
        }
139784
def unit_triangle():
    """"""
    if NO_IMAGES:
        return

    nodes = np.asfortranarray([[0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
    surface = bezier.Surface(nodes, degree=1)
    ax = surface.plot(256)
    ax.axis("scaled")
    _plot_helpers.add_plot_boundary(ax)
    save_image(ax.figure, "unit_triangle.png")
320500
public Point2D getCoord2D(double t) {
		Point2D pt = new Point2D();
		getCoord2D(t, pt);
		return pt;
	}
501036
def _at(self, t):
        """"""
        pos, vel = terra(self.latitude.radians, self.longitude.radians,
                         self.elevation.au, t.gast)
        pos = einsum('ij...,j...->i...', t.MT, pos)
        vel = einsum('ij...,j...->i...', t.MT, vel)
        if self.x:
            R = rot_y(self.x * ASEC2RAD)
            pos = einsum('ij...,j...->i...', R, pos)
        if self.y:
            R = rot_x(self.y * ASEC2RAD)
            pos = einsum('ij...,j...->i...', R, pos)
        # TODO: also rotate velocity

        return pos, vel, pos, None
64819
def angle_subtended(ell, **kwargs):
    
    return_tangent = kwargs.pop('tangent',False)

    con, transform, offset = ell.projection(**kwargs)
    v = N.linalg.norm(N.array(con.major_axes()),axis=1)
    A = N.sort(v)[::-1] # Sort highest values first
    A = N.squeeze(A)
    B = N.linalg.norm(offset)
    if return_tangent: return A/B
    return N.arctan2(A,B)
503815
def unit_vector(self):
        """"""
        return Point2D( self.x / self.magnitude, self.y / self.magnitude )
1042238
def segment_curvature(self, t, use_inf=False):
    

    dz = self.derivative(t)
    ddz = self.derivative(t, n=2)
    dx, dy = dz.real, dz.imag
    ddx, ddy = ddz.real, ddz.imag
    old_np_seterr = np.seterr(invalid='raise')
    try:
        kappa = abs(dx*ddy - dy*ddx)/sqrt(dx*dx + dy*dy)**3
    except (ZeroDivisionError, FloatingPointError):
        # tangent vector is zero at t, use polytools to find limit
        p = self.poly()
        dp = p.deriv()
        ddp = dp.deriv()
        dx, dy = real(dp), imag(dp)
        ddx, ddy = real(ddp), imag(ddp)
        f2 = (dx*ddy - dy*ddx)**2
        g2 = (dx*dx + dy*dy)**3
        lim2 = rational_limit(f2, g2, t)
        if lim2 < 0:  # impossible, must be numerical error
            return 0
        kappa = sqrt(lim2)
    finally:
        np.seterr(**old_np_seterr)
    return kappa