All Samples(1870) | Call(1624) | Derive(0) | Import(246)
atan2(y, x) Return the arc tangent (measured in radians) of y/x. Unlike atan(y/x), the signs of both x and y are considered.
src/h/e/hedge-0.91/examples/maxwell/analytic_solutions.py hedge(Download)
from hedge.tools import \
cyl_bessel_j, \
cyl_bessel_j_prime
from math import sqrt, pi, sin, cos, atan2
import cmath
def __call__(self, x, el):
xy = x[:2]
r = sqrt(xy*xy)
phi = atan2(x[1], x[0])
prev_result = self.adaptee(x, el)
result = []
def __call__(self, x, el):
# coordinates -----------------------------------------------------
xy = x[:2]
r = sqrt(xy*xy)
phi = atan2(x[1], x[0])
z = x[2]
src/o/w/owyl-0.3/examples/boids.py owyl(Download)
import os import random from math import radians, degrees, sin, cos, pi, atan2 pi_2 = pi*2.0 pi_1_2 = pi/2.0 pi_1_4 = pi/4.0
def getFacing(self, tx, ty):
"""Find the facing rotation to local coordinates tx, ty.
"""
return -(atan2(ty, tx) - pi_1_2)
@taskmethod
def move(self, **kwargs):
src/p/y/pyprocessing-0.1.2.3/examples/reference/curvetangent.py pyprocessing(Download)
from pyprocessing import * from math import atan2, cos, sin noFill() curve(5, 26, 73, 24, 73, 61, 15, 65) steps = 6; for i in range(steps+1): t = i / float(steps); x = curvePoint(5, 73, 73, 15, t); y = curvePoint(26, 24, 61, 65, t); #ellipse(x, y, 5, 5); tx = curveTangent(5, 73, 73, 15, t); ty = curveTangent(26, 24, 61, 65, t); a = atan2(ty, tx);
src/h/e/hedge-0.91/examples/poisson/poisson.py hedge(Download)
def boundary_tagger(fvi, el, fn):
from math import atan2, pi
normal = el.face_normals[fn]
if -10/180*pi < atan2(normal[1], normal[0]) < 10/180*pi:
return ["neumann"]
else:
return ["dirichlet"]
src/p/y/pyobjc-framework-Cocoa-2.3/Examples/AppKit/CocoaBindings/GraphicsBindings/JoystickView.py pyobjc-framework-Cocoa(Download)
from Foundation import *
from AppKit import *
from objc import ivar
from math import sin, cos, sqrt, atan2, pi
class JoystickView(NSView):
AngleObservationContext = 2091
# then don't update the angle
# this allows angles to remain constant, but change offset
if not ( self.multipleSelectionForAngle and (event.modifierFlags() & NSShiftKeyMask)):
newAngle = atan2(xOffset, yOffset)
newAngleDegrees = newAngle / (pi/180.0)
if newAngleDegrees < 0:
newAngleDegrees += 360
src/a/s/Astropysics-0.1.dev-r699/astropysics/coords/ephems.py Astropysics(Download)
def equatorialCoordinates(self):
"""
Returns the equatorial coordinates of this object at the current
date/time as a :class:`EquatorialCoordinates` object for the epoch at which
they are derived.
"""
from math import radians,degrees,cos,sin,atan2,sqrt
y = cecl*yg - secl*zg
z = secl*yg + cecl*zg
ra = degrees(atan2(y,x))
dec = degrees(atan2(z,sqrt(x*x+y*y)))
#cache for faster retrieval if JD is not changed
def vapprox(self):
"""
*approximate* Eccentric anamoly - faster than proper numerical solution
of the E-M relation, but lower precision
"""
from math import radians,sin,cos,atan2,sqrt,degrees
xv = cos(E) - e
yv = sqrt(1.0 - e*e) * sin(E)
return degrees(atan2(yv,xv))
def cartesianCoordinates(self,geocentric=False):
"""
Returns the heliocentric ecliptic rectangular coordinates of this object
at the current date/time as an (x,y,z) tuple (in AU)
"""
from math import radians,degrees,cos,sin,atan2,sqrt
xv = a*(cos(E) - e)
yv = a*(sqrt(1.0 - e*e) * sin(E))
v = atan2(yv,xv)
r = sqrt(xv*xv + yv*yv)
sN = sin(Nr)
"""
if geocentric:
from ..obstools import jd_to_epoch
from math import radians,cos,sin,atan2,sqrt
#now get the necessary elements
Mr = radians(self.M)
xv = cos(E) - e
yv = sqrt(1.0 - e*e) * sin(E)
v = atan2(yv,xv)
r = sqrt(xv*xv + yv*yv)
lsun = v + wr
def equatorialCoordinates(self):
"""
Returns the equatorial coordinates of the Sun at the current date/time
as a :class:`EquatorialCoordinates` object for the epoch at which they are
derived.
"""
from math import radians,degrees,cos,sin,atan2,sqrt
y = ys*cos(eclr)
z = ys*sin(eclr)
ra = degrees(atan2(y,x))
dec = degrees(atan2(z,sqrt(x*x+y*y)))
#cache for faster retrieval if JD is not changed
def phase(self,perc=False):
"""
Compute the phase of the moon - 0 is "new", 1 is "full".
if `perc` is True, returns percent illumination.
"""
from math import sqrt,atan2,cos
xs,ys,zs = sun.cartesianCoordinates()
sun.jd = oldsunjd
longsun = atan2(ys,xs)
longmoon = atan2(yg,xg)
latmoon = atan2(zs,sqrt(xg*xg + yg*yg))
src/n/e/netpylab-HEAD/netpylab/paths.py netpylab(Download)
import time from math import log, cos, sin, radians, degrees, atan2, tan, pi, sqrt from xml.dom import minidom import bisect pow2_25 = 2**25
def get_distance(self, other):
radius = 6371000
deltaLat = other.lat-self.lat
deltaLong = other.lon-self.lon
a = (sin(radians(deltaLat)/2))**2
b = cos(radians(other.lat))*cos(radians(self.lat))*(sin(radians(deltaLong)/2))**2
c = 2*atan2(sqrt(a+b), sqrt(1-a-b))
def get_direction(self, other):
deltaLong = other.lon - self.lon
a = sin(radians(deltaLong))*cos(radians(self.lat))
b = cos(radians(other.lat))*sin(radians(self.lat))
c = sin(radians(other.lat))*cos(radians(self.lat))*cos(radians(deltaLong))
direction = degrees(atan2(a, b-c))
return direction #maybe a sign problem ????
src/o/b/obspy-HEAD/obspy.signal/trunk/obspy/signal/rotate.py obspy(Download)
import warnings import numpy as np from math import sqrt, pi, sin, cos, asin, tan, atan, atan2 def rotate_NE_RT(n, e, ba):
pow((cos(U1) * sin(U2) - sin(U1) * cos(U2) * cos(dlon)), 2)
Sin_sigma = sqrt(sqr_sin_sigma)
Cos_sigma = sin(U1) * sin(U2) + cos(U1) * cos(U2) * cos(dlon)
sigma = atan2(Sin_sigma, Cos_sigma)
Sin_alpha = cos(U1) * cos(U2) * sin(dlon) / sin(sigma)
alpha = asin(Sin_alpha)
Cos2sigma_m = cos(sigma) - (2 * sin(U1) * sin(U2) / pow(cos(alpha), 2))
(-3 + 4 * sqr_sin_sigma) * (-3 + 4 * pow(Cos2sigma_m, 2))))
dist = b * A * (sigma - delta_sigma)
alpha12 = atan2((cos(U2) * sin(dlon)),
(cos(U1) * sin(U2) - sin(U1) * cos(U2) * cos(dlon)))
alpha21 = atan2((cos(U1) * sin(dlon)),
(-sin(U1) * cos(U2) + cos(U1) * sin(U2) * cos(dlon)))
src/o/b/obspy.signal-0.4.0/obspy/signal/rotate.py obspy.signal(Download)
import warnings import numpy as np from math import sqrt, pi, sin, cos, asin, tan, atan, atan2 def rotate_NE_RT(n, e, ba):
pow((cos(U1) * sin(U2) - sin(U1) * cos(U2) * cos(dlon)), 2)
Sin_sigma = sqrt(sqr_sin_sigma)
Cos_sigma = sin(U1) * sin(U2) + cos(U1) * cos(U2) * cos(dlon)
sigma = atan2(Sin_sigma, Cos_sigma)
Sin_alpha = cos(U1) * cos(U2) * sin(dlon) / sin(sigma)
alpha = asin(Sin_alpha)
Cos2sigma_m = cos(sigma) - (2 * sin(U1) * sin(U2) / pow(cos(alpha), 2))
(-3 + 4 * sqr_sin_sigma) * (-3 + 4 * pow(Cos2sigma_m, 2))))
dist = b * A * (sigma - delta_sigma)
alpha12 = atan2((cos(U2) * sin(dlon)),
(cos(U1) * sin(U2) - sin(U1) * cos(U2) * cos(dlon)))
alpha21 = atan2((cos(U1) * sin(dlon)),
(-sin(U1) * cos(U2) + cos(U1) * sin(U2) * cos(dlon)))
src/b/a/badger-lib-HEAD/packages/geopy/geopy/distance.py badger-lib(Download)
from math import atan, tan, sin, cos, pi, sqrt, atan2, acos, asin from geopy.units import radians from geopy import units, util from geopy.point import Point # Average great-circle radius in kilometers, from Wikipedia. # Using a sphere with this radius results in an error of up to about 0.5%.
# antipodal points (on opposite ends of the sphere). A more
# complicated formula that is accurate for all distances is: (below)
d = atan2(sqrt((cos_lat2 * sin_delta_lng) ** 2 +
(cos_lat1 * sin_lat2 -
sin_lat1 * cos_lat2 * cos_delta_lng) ** 2),
sin_lat1 * sin_lat2 + cos_lat1 * cos_lat2 * cos_delta_lng)
)
lng2 = lng1 + atan2(
sin(bearing) * sin(d_div_r) * cos(lat1),
cos(d_div_r) - sin(lat1) * sin(lat2)
)
cos_reduced1 * cos_reduced2 * cos_lambda_lng
)
sigma = atan2(sin_sigma, cos_sigma)
sin_alpha = (
cos_reduced1 * cos_reduced2 * sin_lambda_lng / sin_sigma
cos_reduced1 = 1 / sqrt(1 + tan_reduced1 ** 2)
sin_reduced1 = tan_reduced1 * cos_reduced1
sin_bearing, cos_bearing = sin(bearing), cos(bearing)
sigma1 = atan2(tan_reduced1, cos_bearing)
sin_alpha = cos_reduced1 * sin_bearing
cos_sq_alpha = 1 - sin_alpha ** 2
u_sq = cos_sq_alpha * (major ** 2 - minor ** 2) / minor ** 2
sin_sigma, cos_sigma = sin(sigma), cos(sigma)
lat2 = atan2(
sin_reduced1 * cos_sigma + cos_reduced1 * sin_sigma * cos_bearing,
(1 - f) * sqrt(
sin_alpha ** 2 + (
sin_reduced1 * sin_sigma -
cos_reduced1 * cos_sigma * cos_bearing
) ** 2
)
)
lambda_lng = atan2(
sin_sigma * sin_bearing,
)
final_bearing = atan2(
sin_alpha,
cos_reduced1 * cos_sigma * cos_bearing - sin_reduced1 * sin_sigma
)
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next