comparison src/Grids/geometry.jl @ 2056:00b274a118e0 feature/grids/geometry_functions tip

Add review comments
author Vidar Stiernström <vidar.stiernstrom@gmail.com>
date Thu, 12 Feb 2026 14:04:22 +0100
parents 6478c29effce
children
comparison
equal deleted inserted replaced
2053:3a4575fa2702 2056:00b274a118e0
3 tangent::PT 3 tangent::PT
4 4
5 Line{PT}(p::PT, tangent::PT) where PT = new{PT}(p,tangent) 5 Line{PT}(p::PT, tangent::PT) where PT = new{PT}(p,tangent)
6 end 6 end
7 7
8
9 # REVIEW:
10 # 1. Explain the parametrization, i.e., l(1) = p + s*t
11 # 2. Now, if p and t are ints, l(1) returns an int
12 # while l(0.5) returns a float. Is this intended/desirable?
8 """ 13 """
9 Line(p,t) 14 Line(p,t)
10 15
11 A line, as a callable object, starting at `p` with tangent `t`. 16 A line, as a callable object, starting at `p` with tangent `t`.
12 17
45 b::PT 50 b::PT
46 51
47 LineSegment{PT}(p::PT, tangent::PT) where PT = new{PT}(p,tangent) 52 LineSegment{PT}(p::PT, tangent::PT) where PT = new{PT}(p,tangent)
48 end 53 end
49 54
55
56 # REVIEW:
57 # 1. Explain the parametrization.
58 # 2. Now, if a and b are ints, l(1) returns an int
59 # while l(0.5) returns a float. Is this intended/desirable?
60 # 3. Do we want s in [0, 1]? Currently the line segment
61 # can return values "outside" of the interval [a,b].
50 """ 62 """
51 LineSegment(a,b) 63 LineSegment(a,b)
52 64
53 A line segment, as a callable object, from `a` to `b`. 65 A line segment, as a callable object, from `a` to `b`.
54 66
85 97
86 (c::LineSegment)(s) = (1-s)*c.a + s*c.b 98 (c::LineSegment)(s) = (1-s)*c.a + s*c.b
87 99
88 Grids.jacobian(c::LineSegment, s) = c.b - c.a 100 Grids.jacobian(c::LineSegment, s) = c.b - c.a
89 101
102
90 """ 103 """
91 linesegments(ps...) 104 linesegments(ps...)
92 105
93 An array of line segments between the points `ps[1]`, `ps[2]`, and so on. 106 An array of line segments between the points `ps[1]`, `ps[2]`, and so on.
94 107
109 """ 122 """
110 function polygon_edges(ps...) 123 function polygon_edges(ps...)
111 n = length(ps) 124 n = length(ps)
112 return [LineSegment(ps[i], ps[mod1(i+1,n)]) for i ∈ eachindex(ps)] 125 return [LineSegment(ps[i], ps[mod1(i+1,n)]) for i ∈ eachindex(ps)]
113 end 126 end
127
114 128
115 struct Circle{PT,T} 129 struct Circle{PT,T}
116 c::PT 130 c::PT
117 r::T 131 r::T
118 132
153 function Grids.jacobian(C::Circle, θ) 167 function Grids.jacobian(C::Circle, θ)
154 (;r) = C 168 (;r) = C
155 r*@SVector[-sin(θ), cos(θ)] 169 r*@SVector[-sin(θ), cos(θ)]
156 end 170 end
157 171
172
158 struct Arc{PT,T} 173 struct Arc{PT,T}
159 c::Circle{PT,T} 174 c::Circle{PT,T}
160 θ₀::T 175 θ₀::T
161 θ₁::T 176 θ₁::T
162 end 177 end
222 end 237 end
223 238
224 return Arc(Circle(c,abs(r)), θₐ, θₐ+Δθ) 239 return Arc(Circle(c,abs(r)), θₐ, θₐ+Δθ)
225 end 240 end
226 241
242 # REVIEW:
243 # 1. Explain parametrisation
244 # 2. Boundscheck for the parametrisation argumetns, i.e. within [0,1]?
227 """ 245 """
228 TransfiniteInterpolationSurface(c₁, c₂, c₃, c₄) 246 TransfiniteInterpolationSurface(c₁, c₂, c₃, c₄)
229 247
230 A surface defined by the transfinite interpolation of the curves `c₁`, `c₂`, `c₃`, and `c₄`. 248 A surface defined by the transfinite interpolation of the curves `c₁`, `c₂`, `c₃`, and `c₄`.
231 """ 249 """