All Samples(754) | Call(636) | Derive(0) | Import(118)
degrees(x) Convert angle x from radians to degrees.
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
seek_heading = self.getFacing(dx, dy)
my_heading = radians(self.rotation)
rsize = degrees(self.findRotationDelta(my_heading, seek_heading))
rchange = rsize * rate * dt
self.rotation += rchange
continue
my_heading = radians(self.rotation)
rsize = degrees(self.findRotationDelta(my_heading, n_heading))
# Factor in our turning rate and elapsed time.
rchange = rsize * rate * dt
flee_heading = heading_away_from_neighbors
my_heading = radians(self.rotation)
rsize = degrees(self.findRotationDelta(my_heading, flee_heading))
# Factor in our turning rate and elapsed time.
rchange = rsize * rate * dt
my_heading = radians(self.rotation)
# Find the rotation delta
rsize = degrees(self.findRotationDelta(my_heading, seek_heading))
# Factor in our turning rate and elapsed time.
rchange = rsize * rate * dt
src/r/a/Rabbyt-0.8.3/examples/pymunk_integration.py Rabbyt(Download)
import pygame import rabbyt from math import cos, sin, radians, degrees, pi import random import os.path
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 Eapprox(self):
"""
*approximate* Eccentric anamoly - faster than proper numerical solution
of the E-M relation, but lower precision
"""
from math import radians,sin,cos,degrees
Mr = radians(self.M)
e = self.e
return degrees(Mr + e*sin(Mr)*(1.0 + e*cos(Mr)))
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
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
src/w/e/weewx-HEAD/trunk/experimental/astral.py weewx(Download)
import datetime import time from math import cos, sin, tan, acos, asin, atan2, floor, radians, degrees __version__ = "0.3+" __author__ = "Simon Kennedy <python@sffjunkie.co.uk>"
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = _jday_to_jcentury(_jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = _eq_of_time(newt)
solarDec = _sun_declination(newt)
hourangle = _hour_angle_dawn(latitude, solarDec, depression)
delta = longitude - degrees(hourangle)
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = _jday_to_jcentury(_jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = _eq_of_time(newt)
solarDec = _sun_declination(newt)
hourangle = _hour_angle_sunrise(latitude, solarDec)
delta = longitude - degrees(hourangle)
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = _jday_to_jcentury(_jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = _eq_of_time(newt)
solarDec = _sun_declination(newt)
hourangle = _hour_angle_sunset(latitude, solarDec)
delta = longitude - degrees(hourangle)
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = _jday_to_jcentury(_jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = _eq_of_time(newt)
solarDec = _sun_declination(newt)
hourangle = _hour_angle_dusk(latitude, solarDec, depression)
delta = longitude - degrees(hourangle)
elif csz < -1.0:
csz = -1.0
zenith = degrees(acos(csz))
azDenom = (cos(radians(latitude)) * sin(radians(zenith)))
else:
azRad = 1.0
azimuth = 180.0 - degrees(acos(azRad))
if hourangle > 0.0:
azimuth = -azimuth
Etime = y * sin2l0 - 2.0 * e * sinm + 4.0 * e * y * sinm * cos2l0 - \
0.5 * y * y * sin4l0 - 1.25 * e * e * sin2m
return degrees(Etime) * 4.0
def _sun_eq_of_center(juliancentury):
m = _geom_mean_anomaly_sun(juliancentury)
def _sun_declination(juliancentury):
e = _obliquity_correction(juliancentury)
lambd = _sun_apparent_long(juliancentury)
sint = sin(radians(e)) * sin(radians(lambd))
return degrees(asin(sint))
tananum = (cos(radians(e)) * sin(radians(lambd)))
tanadenom = (cos(radians(lambd)))
return degrees(atan2(tananum, tanadenom))
if __name__ == "__main__":
src/a/g/agtl-0.7.1.0-freerunner0/advancedcaching/astral.py agtl(Download)
# Shortened for AGTL by Daniel Fett import datetime from math import cos, sin, tan, acos, asin, atan2, floor, radians, degrees SUN_POSITION_CACHE_DURATION = 3600 # seconds
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = self._jday_to_jcentury(self._jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = self._eq_of_time(newt)
solarDec = self._sun_declination(newt)
hourangle = self._hour_angle_dawn(latitude, solarDec, self._depression)
delta = longitude - degrees(hourangle)
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = self._jday_to_jcentury(self._jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = self._eq_of_time(newt)
solarDec = self._sun_declination(newt)
hourangle = self._hour_angle_sunrise(latitude, solarDec)
delta = longitude - degrees(hourangle)
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = self._jday_to_jcentury(self._jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = self._eq_of_time(newt)
solarDec = self._sun_declination(newt)
hourangle = self._hour_angle_sunset(latitude, solarDec)
delta = longitude - degrees(hourangle)
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = self._jday_to_jcentury(self._jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = self._eq_of_time(newt)
solarDec = self._sun_declination(newt)
hourangle = self._hour_angle_dusk(latitude, solarDec, self._depression)
delta = longitude - degrees(hourangle)
elif csz < -1.0:
csz = -1.0
zenith = degrees(acos(csz))
azDenom = (cos(radians(latitude)) * sin(radians(zenith)))
else:
azRad = 1.0
azimuth = 180.0 - degrees(acos(azRad))
if hourangle > 0.0:
azimuth = -azimuth
elif csz < -1.0:
csz = -1.0
zenith = degrees(acos(csz))
azDenom = (cos(radians(latitude)) * sin(radians(zenith)))
else:
azRad = 1.0
azimuth = 180.0 - degrees(acos(azRad))
if hourangle > 0.0:
azimuth = -azimuth
Etime = y * sin2l0 - 2.0 * e * sinm + 4.0 * e * y * sinm * cos2l0 - \
0.5 * y * y * sin4l0 - 1.25 * e * e * sin2m
return degrees(Etime) * 4.0
def _sun_eq_of_center(self, juliancentury):
m = self._geom_mean_anomaly_sun(juliancentury)
def _sun_declination(self, juliancentury):
e = self._obliquity_correction(juliancentury)
lambd = self._sun_apparent_long(juliancentury)
sint = sin(radians(e)) * sin(radians(lambd))
return degrees(asin(sint))
tananum = (cos(radians(e)) * sin(radians(lambd)))
tanadenom = (cos(radians(lambd)))
return degrees(atan2(tananum, tanadenom))
def get_sun_azimuth_from_fix(self, fix):
if self.sun_cache_time == None or abs((fix.timestamp - self.sun_cache_time).seconds) > SUN_POSITION_CACHE_DURATION:
src/a/s/astral-0.3/src/astral.py astral(Download)
"""
import datetime
from math import cos, sin, tan, acos, asin, atan2, floor, radians, degrees
try:
import pytz
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = self._jday_to_jcentury(self._jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = self._eq_of_time(newt)
solarDec = self._sun_declination(newt)
hourangle = self._hour_angle_dawn(latitude, solarDec, self._depression)
delta = longitude - degrees(hourangle)
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = self._jday_to_jcentury(self._jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = self._eq_of_time(newt)
solarDec = self._sun_declination(newt)
hourangle = self._hour_angle_sunrise(latitude, solarDec)
delta = longitude - degrees(hourangle)
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = self._jday_to_jcentury(self._jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = self._eq_of_time(newt)
solarDec = self._sun_declination(newt)
hourangle = self._hour_angle_sunset(latitude, solarDec)
delta = longitude - degrees(hourangle)
except:
raise AstralError('Sun remains below horizon on this day, at this location.')
delta = longitude - degrees(hourangle)
timeDiff = 4.0 * delta
timeUTC = 720.0 + timeDiff - eqtime
newt = self._jday_to_jcentury(self._jcentury_to_jday(t) + timeUTC / 1440.0)
eqtime = self._eq_of_time(newt)
solarDec = self._sun_declination(newt)
hourangle = self._hour_angle_dusk(latitude, solarDec, self._depression)
delta = longitude - degrees(hourangle)
elif csz < -1.0:
csz = -1.0
zenith = degrees(acos(csz))
azDenom = (cos(radians(latitude)) * sin(radians(zenith)))
else:
azRad = 1.0
azimuth = 180.0 - degrees(acos(azRad))
if hourangle > 0.0:
azimuth = -azimuth
elif csz < -1.0:
csz = -1.0
zenith = degrees(acos(csz))
azDenom = (cos(radians(latitude)) * sin(radians(zenith)))
else:
azRad = 1.0
azimuth = 180.0 - degrees(acos(azRad))
if hourangle > 0.0:
azimuth = -azimuth
Etime = y * sin2l0 - 2.0 * e * sinm + 4.0 * e * y * sinm * cos2l0 - \
0.5 * y * y * sin4l0 - 1.25 * e * e * sin2m
return degrees(Etime) * 4.0
def _sun_eq_of_center(self, juliancentury):
m = self._geom_mean_anomaly_sun(juliancentury)
def _sun_declination(self, juliancentury):
e = self._obliquity_correction(juliancentury)
lambd = self._sun_apparent_long(juliancentury)
sint = sin(radians(e)) * sin(radians(lambd))
return degrees(asin(sint))
tananum = (cos(radians(e)) * sin(radians(lambd)))
tanadenom = (cos(radians(lambd)))
return degrees(atan2(tananum, tanadenom))
def _init_cities(self):
cities = _CITY_INFO.split('\n')
src/p/y/pygear-HEAD/pygear.py pygear(Download)
# Imports from __future__ import division from math import sin, asin, cos, acos, tan, atan, pi, degrees, radians, sqrt from copy import * from sys import maxint from warnings import *
d_yc : cutting point of diameter through tooth center and chord (numeric)
"""
alpha_yt = degrees(acos(self.data.get('d')/d_y* \
cos(radians(self.data.get('alpha_t')))))
s_yt = d_y*((pi+4*self.data.get('x')*tan(radians(self.data.get('alpha_n'))))/ \
2/self.data.get('z')+inv(self.data.get('alpha_t'))-inv(alpha_yt))
psi = radians(self.data.get('tau'))/4+delta
eta = radians(self.data.get('tau'))/4-delta
alpha_yt = acos(self.data.get('d')/d_y*cos(radians(self.data.get('alpha_t'))))
psi_y = psi+inv(self.data.get('alpha_t'))-inv(degrees(alpha_yt))
eta_y = eta-inv(self.data.get('alpha_t'))+inv(degrees(alpha_yt))
return degrees(psi_y), degrees(eta_y)
raise ValueError, 'tool fillet radius negative'
# calculate pressure angle in transverse cross-section
self.data.update({'alpha_t':degrees(atan(tan(radians(self.data.get( \
'alpha_n')))/cos(radians(self.data.get('beta')))))})
# service pitch diameter: value check
# calculate service pressure angle from service pitch diameter if not supplied
if self.data.has_key('d_w') and not self.data.has_key('alpha_wt'):
if not sign(self.data.get('d_w'))==isexternal:
raise ValueError, 'sign of service pitch diameter'
self.data.update({'alpha_wt':degrees(acos(self.data.get('d')/ \
raise ValueError, 'two internal wheels cannot be paired'
self.data.update({'a_d':self.data.get('m_t')*(self.data.get('z')+ \
self.data.get('z_2'))/2})
self.data.update({'alpha_wt':degrees(acos(self.data.get('a_d')/ \
self.data.get('a')*cos(radians(self.data.get( \
'alpha_t')))))})
if self.data.has_key('alpha_wt') and self.data.has_key('z_2'):
self.data.update({'d_Fa':self.data.get('d_a')-2*self.data.get('h_k')})
# calculate tranverse pitch angle
self.data.update({'tau':degrees(2*pi/self.data.get('z'))})
# calculate tooth form coordinates if not supplied
if not self.formcoords:
cos(radians(self.Pinion.data.get('beta')))})
# pitch angles
self.data.update({'alpha_wt':degrees(acos((self.Pinion.data.get('z')+ \
self.Gear.data.get('z'))*self.Pinion.data.get('m_t')* \
cos(radians(self.Pinion.data.get('alpha_t')))/ \
self.data.get('a')/2))})
src/a/s/Astropysics-0.1.dev-r699/astropysics/coords/coordsys.py Astropysics(Download)
def _getRange(self):
if self._range is None:
return None
else:
from math import degrees
if self._range[2] is None:
return degrees(self._range[0]),degrees(self._range[1])
else:
return degrees(self._range[0]),degrees(self._range[1]),degrees(self._range[2])
def __sub__(self,other):
if type(other) == AngularCoordinate:
from math import degrees
res = AngularSeperation()
return AngularSeperation(degrees(other._decval),degrees(self._decval))
else:
res = AngularCoordinate()
def __sub__(self,other):
if isinstance(other,self.__class__):
from math import cos,degrees,acos,asin,sin,sqrt
b1 = self._lat.radians
b2 = other._lat.radians
db = abs(b2 - b1)
#10% faster due to the other overhead
#sep = acos(sin(b1)*sin(b2)+cos(b1)*cos(b2)*cos(dl))
return AngularSeperation(degrees(sep))
# #small angle version
# from math import cos,degrees,sqrt
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_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/p/r/prayertime-2.2/prayertime.py prayertime(Download)
__all__ = ['Season', 'Calendar', 'Prayertime', 'Mazhab', \
'as_pytime', 'as_pydatetime']
from math import degrees, radians, atan, asin, acos, cos, sin, tan
from datetime import date, datetime
from time import strptime
obliquity = 23.439-0.0000004*julian_day
alpha = degrees(atan(cos(radians(obliquity))*tan(radians(lamda))))
if 90 < lamda < 180 :
alpha += 180
elif 100 < lamda < 360:
alpha += 360
ST = 100.46+0.985647352*julian_day
ST = remove_duplication(ST)
self.dec = degrees(asin(sin(radians(obliquity))*sin(radians(lamda))))
asr_alt = 0
if self.mazhab == Mazhab.Hanafi :
asr_alt = 90 - degrees(atan(2+tan(radians(abs(latitude - self.dec)))))
else:
asr_alt = 90 - degrees(atan(1 + tan(radians(abs(latitude - self.dec)))))
def _equation(self, alt):
#return RadToDeg*acos((sin(alt*DegToRad)-sin(self.dec*DegToRad)*sin(self.coordinate.latitude*DegToRad))/(cos(self.dec*DegToRad)*cos(self.coordinate.latitude*DegToRad)))
return degrees( acos( (sin(radians(alt)) - sin(radians(self.dec)) * sin(radians(self.coordinate.latitude)))/(cos(radians(self.dec))*cos(radians(self.coordinate.latitude)))))
def report(self):
"""Simple report of all prayertimes."""
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next