polishing, and using numpy's deg2rad/rad2deg
This commit is contained in:
parent
7d4ff278cb
commit
9078d70af0
|
@ -1,22 +1,16 @@
|
||||||
# some utility functions
|
# damask utility functions
|
||||||
import math
|
import math
|
||||||
try:
|
try:
|
||||||
import numpy
|
import numpy
|
||||||
except:
|
except:
|
||||||
numpy=None
|
numpy=None
|
||||||
|
|
||||||
|
# Matlab like trigonometric functions that take and return angles in degrees.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for f in ['cos', 'sin', 'tan']:
|
for f in ['cos', 'sin', 'tan']:
|
||||||
exec('def %sd(deg): return ((numpy or math).%s(deg/180.*math.pi))'%(f,f))
|
|
||||||
if numpy:
|
if numpy:
|
||||||
exec('def a%sd(val): return (numpy.arc%s(val)*180./math.pi)'%(f,f))
|
exec('def %sd(deg): return (numpy.%s(numpy.deg2rad(deg)))'%(f,f))
|
||||||
|
exec('def a%sd(val): return (numpy.rad2deg(numpy.arc%s(val)))'%(f,f))
|
||||||
else:
|
else:
|
||||||
|
exec('def %sd(deg): return (math.%s(deg/180.*math.pi))'%(f,f))
|
||||||
exec('def a%sd(val): return (math.a%s(val)*180./math.pi)'%(f,f))
|
exec('def a%sd(val): return (math.a%s(val)*180./math.pi)'%(f,f))
|
||||||
# Matlab like functions to allow for cosd(degree),...
|
|
||||||
# it is open how these compare to the numpy.cos, which can operate on arrays
|
|
||||||
# ->full array compatibility can be achieved through numpy.deg2rad|rad2deg
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue