164 |
bool success; |
bool success; |
165 |
ZVec in = project2circle(node.ctr + dir, node.ctr, fcenter, |
ZVec in = project2circle(node.ctr + dir, node.ctr, fcenter, |
166 |
frad, -1, &success); |
frad, -1, &success); |
167 |
if(success) return; |
if(!success) return; |
168 |
this->aend = Vec(in-fcenter).atan(); |
this->aend = Vec(in-fcenter).atan(); |
169 |
while(aend - astart >= M_PI) aend -= 2 * M_PI; |
while(aend - astart >= M_PI) aend -= 2 * M_PI; |
170 |
while(astart - aend >= M_PI) aend += 2 * M_PI; |
while(astart - aend >= M_PI) aend += 2 * M_PI; |
195 |
return dirtang.cross(conn.dir) * dirtang.cross(dir) >= 0 && |
return dirtang.cross(conn.dir) * dirtang.cross(dir) >= 0 && |
196 |
conn.dir.cross(dirtang) * conn.dir.cross(dir) >= 0; |
conn.dir.cross(dirtang) * conn.dir.cross(dir) >= 0; |
197 |
} |
} |
198 |
|
/** Returns true if either of the directions where the circles |
199 |
|
* are tangent is inside the other fillet area. |
200 |
|
*/ |
201 |
bool overlaps(const CircleCircleFillet &other) const { |
bool overlaps(const CircleCircleFillet &other) const { |
202 |
return infillet(other.dirtang) || other.infillet(dirtang); |
return infillet(other.dirtang) || other.infillet(dirtang); |
203 |
} |
} |
235 |
} |
} |
236 |
}; |
}; |
237 |
|
|
238 |
|
template<class S1, class S2> struct LerpFilletSpan { |
239 |
|
const S1 &s1; |
240 |
|
const S2 &s2; |
241 |
|
float fract; |
242 |
|
LerpFilletSpan(const S1 &s1, const S2 &s2, float fract) : s1(s1), s2(s2), fract(fract) { } |
243 |
|
|
244 |
|
ZVec point(float fract, ZVec *intern = 0) const { |
245 |
|
ZVec i1, i2; |
246 |
|
ZVec res = lerp(s1.point(fract, &i1), s2.point(fract, &i2), fract); |
247 |
|
if(intern) |
248 |
|
*intern = lerp(i1, i2, fract); |
249 |
|
return res; |
250 |
|
} |
251 |
|
}; |
252 |
|
template<class S1, class S2> LerpFilletSpan<S1, S2> makeLerpFilletSpan( |
253 |
|
const S1 &s1, const S2 &s2, float fract) { |
254 |
|
return LerpFilletSpan<S1,S2>(s1, s2, fract); |
255 |
|
} |
256 |
|
|
257 |
struct CircularNodeSpan { |
struct CircularNodeSpan { |
258 |
const CircularNode &node; |
const CircularNode &node; |