本文整理汇总了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
示例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
示例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
示例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
示例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
示例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
示例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
示例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)
示例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
示例10: acos
def acos(x):
if x > 1: return _acos(1)
if x < -1: return _acos(-1)
return _acos(x)
示例11: acos
def acos(x):
return _acos(x) if common._use_radians else _deg(_acos(x))
示例12: Angle
def Angle( self, other ):
'''
Angle between two 3 vectors.
'''
return _acos( self.Unit() ** other.Unit() )