1-
2-
31export Ray
42
5-
6-
7- # # Standard interval
8-
9- # angle is (false==0) and π (true==1)
10- # or ranges from (-1,1]. We use 1 as 1==true.
11- # orientation true means oriented out
123"""
13- Ray{a}(c,o)
4+ Ray{a}(c,L, o)
145
15- represents a ray at angle `a` starting at `c`, with orientation out to
6+ represents a scaled ray (with scale factor L) at angle `a` starting at `c`, with orientation out to
167infinity (`o = true`) or back from infinity (`o = false`).
178"""
189struct Ray{angle,T<: Number } <: SegmentDomain{T}
1910 center:: T
11+ L:: T
2012 orientation:: Bool
21- Ray {angle,T} (c,o) where {angle,T} = new {angle,T} (c,o)
22- Ray {angle,T} (c) where {angle,T} = new {angle,T} (c,true )
23- Ray {angle,T} () where {angle,T} = new {angle,T} (zero (T),true )
13+ Ray {angle,T} (c,L,o) where {angle,T} = new {angle,T} (c,L,o)
14+ Ray {angle,T} (c,o) where {angle,T} = new {angle,T} (c,one (T),o)
15+ Ray {angle,T} (c) where {angle,T} = new {angle,T} (c,one (T),true )
16+ Ray {angle,T} () where {angle,T} = new {angle,T} (zero (T),one (T),true )
2417 Ray {angle,T} (r:: Ray{angle,T} ) where {angle,T} = r
2518end
2619
27- const RealRay{T} = Union{Ray{false ,T},Ray{true ,T}}
28-
29- Ray {a} (c,o) where {a} = Ray {a,typeof(c)} (c,o)
20+ Ray {a} (c,L,o) where {a} = Ray {a,typeof(c)} (c,L,o)
21+ Ray {a} (c,o) where {a} = Ray {a,typeof(c)} (c,one (typeof (c)),o)
3022Ray {a} (c:: Number ) where {a} = Ray {a,typeof(c)} (c)
3123Ray {a} () where {a} = Ray {a,Float64} ()
3224
3325angle (d:: Ray{a} ) where {a} = a* π
3426
3527# ensure the angle is always in (-1,1]
36- Ray (c,a,o) = Ray {a==0 ? false : (abs(a)≈(1.0π) ? true : mod(a/π-1,-2)+1),typeof(c)} (c,o)
37- Ray (c,a) = Ray (c,a,true )
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)
30+ Ray (c,a) = Ray (c,a,one (typeof (c)),true )
3831
3932Ray () = Ray {false} ()
4033
@@ -47,9 +40,9 @@ function convert(::Type{Ray}, d::AbstractInterval)
4740 @assert abs (a)== Inf || abs (b)== Inf
4841
4942 if abs (b)== Inf
50- Ray (a,angle (b),true )
43+ Ray (a,angle (b),one ( typeof (a)), true )
5144 else # abs(a)==Inf
52- Ray (b,angle (a),false )
45+ Ray (b,angle (a),one ( typeof (a)), false )
5346 end
5447end
5548Ray (d:: AbstractInterval ) = convert (Ray, d)
@@ -66,7 +59,7 @@ isempty(::Ray) = false
6659
6760function mobiuspars (d:: Ray )
6861 s= (d. orientation ? 1 : - 1 )
69- α= conj (cisangle (d))
62+ α= conj (cisangle (d))/ d . L
7063 c= d. center
7164 s* α,- s* (1 + α* c),α,1 - α* c
7265end
@@ -84,40 +77,37 @@ ray_invfromcanonicalD(x) = (x-1)^2/2
8477
8578
8679for op in (:ray_tocanonical ,:ray_tocanonicalD )
87- @eval $ op (o,x)= (o ? 1 : - 1 )* $ op (x)
80+ @eval $ op (L, o,x)= (o ? 1 : - 1 )* $ op (x/ L )
8881end
89- ray_fromcanonical (o,x)= ray_fromcanonical ((o ? 1 : - 1 )* x)
90- ray_fromcanonicalD (o,x)= (o ? 1 : - 1 )* ray_fromcanonicalD ((o ? 1 : - 1 )* x)
91- ray_invfromcanonicalD (o,x)= (o ? 1 : - 1 )* ray_invfromcanonicalD ((o ? 1 : - 1 )* x)
82+
83+ ray_fromcanonical (L,o,x)= L* ray_fromcanonical ((o ? 1 : - 1 )* x)
84+ ray_fromcanonicalD (L,o,x)= L* (o ? 1 : - 1 )* ray_fromcanonicalD ((o ? 1 : - 1 )* x)
85+ ray_invfromcanonicalD (L,o,x)= L* (o ? 1 : - 1 )* ray_invfromcanonicalD ((o ? 1 : - 1 )* x)
9286
9387cisangle (:: Ray{a} ) where {a}= cis (a* π)
9488cisangle (:: Ray{false} )= 1
9589cisangle (:: Ray{true} )= - 1
9690
9791tocanonical (d:: Ray ,x) =
98- ray_tocanonical (d. orientation,conj (cisangle (d)).* (x- d. center))
92+ ray_tocanonical (d. L,d . orientation,conj (cisangle (d)).* (x- d. center))
9993tocanonicalD (d:: Ray ,x) =
100- conj (cisangle (d)).* ray_tocanonicalD (d. orientation,conj (cisangle (d)).* (x- d. center))
101- fromcanonical (d:: Ray ,x) = cisangle (d)* ray_fromcanonical (d. orientation,x)+ d. center
102- fromcanonical (d:: Ray{false} ,x) = ray_fromcanonical (d. orientation,x)+ d. center
103- fromcanonical (d:: Ray{true} ,x) = - ray_fromcanonical (d. orientation,x)+ d. center
104- fromcanonicalD (d:: Ray ,x) = cisangle (d)* ray_fromcanonicalD (d. orientation,x)
105- invfromcanonicalD (d:: Ray ,x) = conj (cisangle (d))* ray_invfromcanonicalD (d. orientation,x)
106-
107-
108-
109-
94+ conj (cisangle (d)).* ray_tocanonicalD (d. L,d. orientation,conj (cisangle (d)).* (x- d. center))
95+ fromcanonical (d:: Ray ,x) = cisangle (d)* ray_fromcanonical (d. L,d. orientation,x)+ d. center
96+ fromcanonical (d:: Ray{false} ,x) = ray_fromcanonical (d. L,d. orientation,x)+ d. center
97+ fromcanonical (d:: Ray{true} ,x) = - ray_fromcanonical (d. L,d. orientation,x)+ d. center
98+ fromcanonicalD (d:: Ray ,x) = cisangle (d)* ray_fromcanonicalD (d. L,d. orientation,x)
99+ invfromcanonicalD (d:: Ray ,x) = conj (cisangle (d))* ray_invfromcanonicalD (d. L,d. orientation,x)
110100arclength (d:: Ray ) = Inf
111101
112- == (d:: Ray{a} ,m:: Ray{a} ) where {a} = d. center == m. center
102+ == (d:: Ray{a} ,m:: Ray{a} ) where {a} = d. center == m. center && d . L == m . L
113103
114104
115105mappoint (a:: Ray{false} , b:: Ray{false} , x:: Number ) =
116- x - a . center + b. center
106+ b . center + b. L / a . L * (x - a . center)
117107
118108
119109function mappoint (a:: Ray , b:: Ray , x:: Number )
120110 d = x - a. center;
121- k = d * exp ((angle (b)- angle (d))* im)
111+ k = b . L / a . L * d * exp ((angle (b)- angle (d))* im)
122112 k + b. center
123113end
0 commit comments