Python scipy 模块,sin() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用scipy.sin()

项目:nodebox1-generative-tools    作者:x-raizor    | 项目源码 | 文件源码
def rvs( self ):
        if self.ss == 0:
            x = random.random() * self.w
            y = random.random() * self.h
            self.set_point( x, y )
        while self.qs:
            x_idx = int( random.random() * self.qs )
            s = self.queue[ x_idx ]
            for y_idx in range( self.n ):
                a = 2 * scipy.pi * random.random()
                b = scipy.sqrt( self.A * random.random() + self.r2 )
                x = s[0] + b*scipy.cos( a )
                y = s[1] + b*scipy.sin( a )
                if( x >= 0 )and( x < self.w ):
                    if( y >= 0 )and( y < self.h ):
                        if( self.distance( x, y ) ):
                            self.set_point( x, y )
            del self.queue[x_idx]
            self.qs -= 1
        sample = list( filter( None, self.grid ) )
        sample = scipy.asfarray( sample )
        return sample
项目:Jensen3D    作者:byuflowlab    | 项目源码 | 文件源码
def rotate(x, y, U_direction_radians):
    x_r = x*np.cos(U_direction_radians)-y*np.sin(U_direction_radians)
    y_r = x*np.sin(U_direction_radians)+y*np.cos(U_direction_radians)
    return x_r, y_r
项目:Cascade-CNN-Face-Detection    作者:gogolgrind    | 项目源码 | 文件源码
def ellipse2bbox(a, b, angle, cx, cy):
        a, b = max(a, b), min(a, b)
        ca = sp.cos(angle)
        sa = sp.sin(angle)
        if sa == 0.0:
            cta = 2.0 / sp.pi
        else:
            cta = ca / sa

        if ca == 0.0:
            ta = sp.pi / 2.0
        else:
            ta = sa / ca

        x = lambda t: cx + a * sp.cos(t) * ca - b * sp.sin(t) * sa


        y = lambda t: cy + b * sp.sin(t) * ca + a * sp.cos(t) * sa

        # x = cx + a * cos(t) * cos(angle) - b * sin(t) * sin(angle)
        # tan(t) = -b * tan(angle) / a
        tx1 = sp.arctan(-b * ta / a)
        tx2 = tx1 - sp.pi
        x1, y1 = x(tx1), y(tx1)
        x2, y2 = x(tx2), y(tx2)

        # y = cy + b * sin(t) * cos(angle) + a * cos(t) * sin(angle)
        # tan(t) = b * cot(angle) / a
        ty1 = sp.arctan(b * cta / a)
        ty2 = ty1 - sp.pi
        x3, y3 = x(ty1), y(ty1)
        x4, y4 = x(ty2), y(ty2)

        minx, maxx = Util.minmax([x1, x2, x3, x4])
        miny, maxy = Util.minmax([y1, y2, y3, y4])
        return sp.floor(minx), sp.floor(miny), sp.ceil(maxx), sp.ceil(maxy)