Skip to content

Commit

Permalink
Some additions of sincos() (#44)
Browse files Browse the repository at this point in the history
Implementing sincos(), introduced in 68e1a2a to a few more places.
  • Loading branch information
TestSubjector authored and giordano committed Oct 2, 2017
1 parent 10ee386 commit 97219f5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
12 changes: 4 additions & 8 deletions src/co_aberration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ function _co_aberration(jd::T, ra::T, dec::T, eps::T) where {T<:AbstractFloat}
sunlong = sunpos(jd, radians=true)[3]
e = @evalpoly t 0.016708634 -0.000042037 -0.0000001267
pe = @evalpoly t 102.93735 1.71946 0.00046
cd = cosd(dec)
sd = sind(dec)
sd, cd = sincos(deg2rad(dec))
ce = cos(eps)
te = tan(eps)
cp = cosd(pe)
sp = sind(pe)
cs = cos(sunlong)
ss = sin(sunlong)
ca = cosd(ra)
sa = sind(ra)
sp, cp = sincos(deg2rad(pe))
ss, cs = sincos(sunlong)
sa, ca = sincos(deg2rad(ra))
t1 = (cs*ce*(te*cd - sa*sd) + ca*sd*ss)
t2 = (cp*ce*(te*cd - sa*sd) + ca*sd*sp)
d_ra = 20.49552*(e*(ca*cp*ce + sa*sp) - ca*cs*ce - sa*ss)/cd
Expand Down
3 changes: 1 addition & 2 deletions src/co_nutate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
function _co_nutate(jd::T, ra::T, dec::T) where {T<:AbstractFloat}
d_psi, d_eps = nutate(jd)
eps = mean_obliquity(jd) + sec2rad(d_eps)
ce = cos(eps)
se = sin(eps)
se, ce = sincos(eps)
x = cosd(ra) * cosd(dec)
y = sind(ra) * cosd(dec)
z = sind(dec)
Expand Down
2 changes: 1 addition & 1 deletion src/eqpole.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function _eqpole(l::T, b::T, southpole::Bool) where {T<:AbstractFloat}
l = deg2rad(sgn*l)
b = deg2rad(sgn*b)
r = 18 * sqrt(2 * (1 - sin(b))) * 3.53553391
return r*sin(l), r*cos(l)
return r .* sincos(l)
end

"""
Expand Down
6 changes: 2 additions & 4 deletions src/kepler_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ function kepler_solver(M::T, e::T) where {T<:AbstractFloat}
w = cbrt(abs2(abs(r) + sqrt(q * q * q + r * r)))
# equation (15)
E1 = (2 * r * w / @evalpoly(w, q * q, q, 1) + M)/d
# equation (26). TODO: here we can use sincos, when will be available.
f2 = e * sin(E1)
# equation (26) & equation (27)
f2, f3 = e .* sincos(E1)
# equation (21)
f0 = E1 - f2 - M
# equation (27)
f3 = e * cos(E1)
# equation (25)
f1 = 1 - f3
# equation (22)
Expand Down
5 changes: 2 additions & 3 deletions src/precess_xyz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ function precess_xyz(x::T, y::T, z::T, equinox1::T, equinox2::T) where {T<:Abstr
# precess the ra and dec
ra, dec = precess(ra, dec, equinox1, equinox2, radians=true)
# convert back to x, y, z
xunit = cos(ra)*cos(dec)
yunit = sin(ra)*cos(dec)
zunit = sin(dec)
zunit, cos_dec = sincos(dec)
yunit, xunit = cos_dec .* sincos(ra)
return xunit*del, yunit*del, zunit*del
end

Expand Down

0 comments on commit 97219f5

Please sign in to comment.