当前位置: 首页>>代码示例>>Python>>正文


Python math._acos函数代码示例

本文整理汇总了Python中math._acos函数的典型用法代码示例。如果您正苦于以下问题:Python _acos函数的具体用法?Python _acos怎么用?Python _acos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_acos函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: vonmisesvariate

 def vonmisesvariate(self, mu, kappa):
     random = self.random
     if kappa <= 9.9999999999999995e-007:
         return TWOPI * random()
     
     a = 1.0 + _sqrt(1.0 + 4.0 * kappa * kappa)
     b = (a - _sqrt(2.0 * a)) / 2.0 * kappa
     r = (1.0 + b * b) / 2.0 * b
     while 1:
         u1 = random()
         z = _cos(_pi * u1)
         f = (1.0 + r * z) / (r + z)
         c = kappa * (r - f)
         u2 = random()
         if u2 >= c * (2.0 - c):
             pass
         if not (u2 > c * _exp(1.0 - c)):
             break
         
     u3 = random()
     if u3 > 0.5:
         theta = mu % TWOPI + _acos(f)
     else:
         theta = mu % TWOPI - _acos(f)
     return theta
开发者ID:Toonerz,项目名称:Toontown-2003,代码行数:25,代码来源:random.py

示例2: vonmisesvariate

    def vonmisesvariate(self, mu, kappa):
        """Circular data distribution.
        
        mu is the mean angle, expressed in radians between 0 and 2*pi, and
        kappa is the concentration parameter, which must be greater than or
        equal to zero.  If kappa is equal to zero, this distribution reduces
        to a uniform random angle over the range 0 to 2*pi.
        
        """
        random = self.random
        if kappa <= 1e-06:
            return TWOPI * random()
        s = 0.5 / kappa
        r = s + _sqrt(1.0 + s * s)
        while 1:
            u1 = random()
            z = _cos(_pi * u1)
            d = z / (r + z)
            u2 = random()
            if u2 < 1.0 - d * d or u2 <= (1.0 - d) * _exp(d):
                break

        q = 1.0 / r
        f = (q + z) / (1.0 + q * z)
        u3 = random()
        if u3 > 0.5:
            theta = (mu + _acos(f)) % TWOPI
        else:
            theta = (mu - _acos(f)) % TWOPI
        return theta
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:30,代码来源:random.py

示例3: vonmisesvariate

    def vonmisesvariate(self, mu, kappa):
        """Circular data distribution.
        
        mu is the mean angle, expressed in radians between 0 and 2*pi, and
        kappa is the concentration parameter, which must be greater than or
        equal to zero.  If kappa is equal to zero, this distribution reduces
        to a uniform random angle over the range 0 to 2*pi.
        
        """
        random = self.random
        if kappa <= 1e-06:
            return TWOPI * random()
        a = 1.0 + _sqrt(1.0 + 4.0 * kappa * kappa)
        b = (a - _sqrt(2.0 * a)) / (2.0 * kappa)
        r = (1.0 + b * b) / (2.0 * b)
        while 1:
            u1 = random()
            z = _cos(_pi * u1)
            f = (1.0 + r * z) / (r + z)
            c = kappa * (r - f)
            u2 = random()
            if u2 < c * (2.0 - c) or u2 <= c * _exp(1.0 - c):
                break

        u3 = random()
        if u3 > 0.5:
            theta = mu % TWOPI + _acos(f)
        else:
            theta = mu % TWOPI - _acos(f)
        return theta
开发者ID:AkiSyndicat,项目名称:AbletonLive9_RemoteScripts,代码行数:30,代码来源:random.py

示例4: vonmisesvariate

    def vonmisesvariate(self, mu, kappa):
        """Circular data distribution.

        mu is the mean angle, expressed in radians between 0 and 2*pi, and
        kappa is the concentration parameter, which must be greater than or
        equal to zero.  If kappa is equal to zero, this distribution reduces
        to a uniform random angle over the range 0 to 2*pi.

        """
        # mu:    mean angle (in radians between 0 and 2*pi)
        # kappa: concentration parameter kappa (>= 0)
        # if kappa = 0 generate uniform random angle

        # Based upon an algorithm published in: Fisher, N.I.,
        # "Statistical Analysis of Circular Data", Cambridge
        # University Press, 1993.

        # Thanks to Magnus Kessler for a correction to the
        # implementation of step 4.

        random = self.random
        if kappa <= 1e-6:
            return TWOPI * random()

        a = 1.0 + _sqrt(1.0 + 4.0 * kappa * kappa)
        b = (a - _sqrt(2.0 * a)) / (2.0 * kappa)
        r = (1.0 + b * b) / (2.0 * b)

        while 1:
            u1 = random()

            z = _cos(_pi * u1)
            f = (1.0 + r * z) / (r + z)
            c = kappa * (r - f)

            u2 = random()

            if not (u2 >= c * (2.0 - c) and u2 > c * _exp(1.0 - c)):
                break

        u3 = random()
        if u3 > 0.5:
            theta = (mu % TWOPI) + _acos(f)
        else:
            theta = (mu % TWOPI) - _acos(f)

        return theta
开发者ID:zhoupan,项目名称:OpenModelSphereMirror,代码行数:47,代码来源:random.py

示例5: vonmisesvariate

    def vonmisesvariate(self, mu, kappa):
        """Circular data distribution.

        mu is the mean angle, expressed in radians between 0 and 2*pi, and
        kappa is the concentration parameter, which must be greater than or
        equal to zero.  If kappa is equal to zero, this distribution reduces
        to a uniform random angle over the range 0 to 2*pi.

        """
        # mu:    mean angle (in radians between 0 and 2*pi)
        # kappa: concentration parameter kappa (>= 0)
        # if kappa = 0 generate uniform random angle

        # Based upon an algorithm published in: Fisher, N.I.,
        # "Statistical Analysis of Circular Data", Cambridge
        # University Press, 1993.

        # Thanks to Magnus Kessler for a correction to the
        # implementation of step 4.

        random = self.random
        if kappa <= 1e-6:
            return TWOPI * random()

        s = 0.5 / kappa
        r = s + _sqrt(1.0 + s * s)

        while 1:
            u1 = random()
            z = _cos(_pi * u1)

            d = z / (r + z)
            u2 = random()
            if u2 < 1.0 - d * d or u2 <= (1.0 - d) * _exp(d):
                break

        q = 1.0 / r
        f = (q + z) / (1.0 + q * z)
        u3 = random()
        if u3 > 0.5:
            theta = (mu + _acos(f)) % TWOPI
        else:
            theta = (mu - _acos(f)) % TWOPI

        return theta
开发者ID:zegab,项目名称:diane,代码行数:45,代码来源:random.py

示例6: vonmisesvariate

 def vonmisesvariate(self, mu, kappa):
     random = self.random
     if kappa <= 1e-06:
         return TWOPI*random()
     s = 0.5/kappa
     r = s + _sqrt(1.0 + s*s)
     while True:
         u1 = random()
         z = _cos(_pi*u1)
         d = z/(r + z)
         u2 = random()
         if u2 < 1.0 - d*d or u2 <= (1.0 - d)*_exp(d):
             break
     q = 1.0/r
     f = (q + z)/(1.0 + q*z)
     u3 = random()
     if u3 > 0.5:
         theta = (mu + _acos(f)) % TWOPI
     else:
         theta = (mu - _acos(f)) % TWOPI
     return theta
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:21,代码来源:random.py

示例7: vonmisesvariate

    def vonmisesvariate(self, mu, kappa):
        random = self.random
        if kappa <= 1e-06:
            return TWOPI * random()
        a = 1.0 + _sqrt(1.0 + 4.0 * kappa * kappa)
        b = (a - _sqrt(2.0 * a)) / (2.0 * kappa)
        r = (1.0 + b * b) / (2.0 * b)
        while 1:
            u1 = random()
            z = _cos(_pi * u1)
            f = (1.0 + r * z) / (r + z)
            c = kappa * (r - f)
            u2 = random()
            if u2 < c * (2.0 - c) or u2 <= c * _exp(1.0 - c):
                break

        u3 = random()
        if u3 > 0.5:
            theta = mu % TWOPI + _acos(f)
        else:
            theta = mu % TWOPI - _acos(f)
        return theta
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:22,代码来源:random.py

示例8: acos

def acos(c):
    """acos -  Safe inverse cosine

       Input argument c is shrunk to admissible interval
       to avoid case where a small rounding error causes
       a math domain error.
    """
    from math import acos as _acos

    if c > 1:
        c = 1
    if c < -1:
        c = -1

    return _acos(c)
开发者ID:warex03,项目名称:WebSAFE,代码行数:15,代码来源:geodesy.py

示例9: get_spherical_rotatation

def get_spherical_rotatation(p1, p2, width, height, theta_multiplier):
    v1 = get_sphere_mapping(p1[0], p1[1], width, height)
    v2 = get_sphere_mapping(p2[0], p2[1], width, height)

    d = min(max([dot(v1, v2), -1]), 1)

    if abs(d - 1.0) < 0.000001:
        return None

    raxis = norm( cross(v1, v2) )
    rtheta = theta_multiplier * rad2deg * _acos(d)

    glPushMatrix()
    glLoadIdentity()
    glRotatef(rtheta, *raxis)
    mat = (c_float*16)()
    glGetFloatv(GL_MODELVIEW_MATRIX, mat)
    glPopMatrix()

    return mat
开发者ID:A-turing-machine,项目名称:sympy,代码行数:20,代码来源:plot_rotation.py

示例10: acos

def acos(x):
    if x > 1: return _acos(1)
    if x < -1: return _acos(-1)
    return _acos(x)
开发者ID:Web5design,项目名称:divisi,代码行数:4,代码来源:mds.py

示例11: acos

def acos(x):
    return _acos(x) if common._use_radians else _deg(_acos(x))
开发者ID:qandak,项目名称:sumcalc,代码行数:2,代码来源:mathfuncs.py

示例12: Angle

 def Angle( self, other ):
     '''
         Angle between two 3 vectors.
     '''
     return _acos( self.Unit() ** other.Unit() )
开发者ID:gonzaponte,项目名称:Python,代码行数:5,代码来源:Array.py

示例13:

"""Random variable generators.
开发者ID:mcyril,项目名称:ravel-ftn,代码行数:1,代码来源:random.py


注:本文中的math._acos函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。