@@ -25,8 +25,20 @@ Ray{a}() where {a} = Ray{a,Float64}()
2525angle (d:: Ray{a} ) where {a} = a* π
2626
2727# ensure the angle is always in (-1,1]
28- Ray (c,a,L,o) = Ray {a==0 ? false : (abs(a)≈(1.0π) ? true : mod(a/π-1,-2)+1),typeof(c)} (c,L,o)
29- Ray (c,a,o) = Ray {a==0 ? false : (abs(a)≈(1.0π) ? true : mod(a/π-1,-2)+1),typeof(c)} (c,one (typeof (c)),o)
28+ @inline function _Ray (c,a,L,o)
29+ angle = if iszero (a)
30+ false
31+ else
32+ (abs (a)≈ (1.0 π) ? true : mod (a/ π- 1 ,- 2 )+ 1 )
33+ end
34+ Ray {angle,typeof(c)} (c,L,o)
35+ end
36+ @static if VERSION >= v " 1.8"
37+ Base. @constprop :aggressive Ray (c,a,L,o) = _Ray (c,a,L,o)
38+ else
39+ Ray (c,a,L,o) = _Ray (c,a,L,o)
40+ end
41+ Ray (c,a,o) = Ray (c,a,one (typeof (c)),o)
3042Ray (c,a) = Ray (c,a,one (typeof (c)),true )
3143
3244Ray () = Ray {false} ()
@@ -35,14 +47,17 @@ Ray() = Ray{false}()
3547
3648# #deal with vector
3749
50+ _rayangle (x) = angle (x)
51+ _rayangle (x:: Real ) = 0
52+
3853function convert (:: Type{Ray} , d:: AbstractInterval )
3954 a,b = endpoints (d)
4055 @assert abs (a)== Inf || abs (b)== Inf
4156
4257 if abs (b)== Inf
43- Ray (a,angle (b),one (typeof (a)),true )
58+ Ray (a,_rayangle (b),one (typeof (a)),true )
4459 else # abs(a)==Inf
45- Ray (b,angle (a),one (typeof (a)),false )
60+ Ray (b,_rayangle (a),one (typeof (a)),false )
4661 end
4762end
4863Ray (d:: AbstractInterval ) = strictconvert (Ray, d)
0 commit comments