88 |
/** The distance from the center to the middle of the connection. |
/** The distance from the center to the middle of the connection. |
89 |
*/ |
*/ |
90 |
float d; |
float d; |
91 |
/** The thickness of the connection at the middle. |
/** The thickness(radius) of the connection at the middle. |
92 |
*/ |
*/ |
93 |
float t; |
float t; |
94 |
/** Whether we're looking at the clockwise (+1) or counterclockwise (-1) side. |
/** Whether we're looking at the clockwise (+1) or counterclockwise (-1) side. |
129 |
z(z) { |
z(z) { |
130 |
dir = dirVec(a); |
dir = dirVec(a); |
131 |
norm = dir.cw90() * sign; |
norm = dir.cw90() * sign; |
132 |
endPoint = node.ctr + d * dir + t/2 * norm; |
endPoint = node.ctr + d * dir + t * norm; |
133 |
} |
} |
134 |
|
|
135 |
/** Project a given point to the connecting line. |
/** Project a given point to the connecting line. |
189 |
const LinearConnectionHalf &conn, |
const LinearConnectionHalf &conn, |
190 |
float ta |
float ta |
191 |
) : node(node), conn(conn), tangentAngle(ta) { |
) : node(node), conn(conn), tangentAngle(ta) { |
192 |
r1 = (.5*conn.t - sin(ta) * node.r) / (sin(ta) - 1); |
r1 = (conn.t - sin(ta) * node.r) / (sin(ta) - 1); |
193 |
|
|
194 |
x0 = cos(ta) * node.r; |
x0 = cos(ta) * node.r; |
195 |
|
|
207 |
ZVec point(float fract, ZVec *intern = 0) const { |
ZVec point(float fract, ZVec *intern = 0) const { |
208 |
float angle = lerp(0, cutangle, fract); |
float angle = lerp(0, cutangle, fract); |
209 |
|
|
210 |
float y = (1-cos(angle)) * r1 + conn.t / 2; |
float y = (1-cos(angle)) * r1 + conn.t; |
211 |
|
|
212 |
float x = x1 - sin(angle) * r1 - x0; |
float x = x1 - sin(angle) * r1 - x0; |
213 |
|
|
344 |
) : node(node), conn(conn), tangentAngle(ta) |
) : node(node), conn(conn), tangentAngle(ta) |
345 |
{ |
{ |
346 |
eno = Vec(-cos(tangentAngle), sin(tangentAngle)); |
eno = Vec(-cos(tangentAngle), sin(tangentAngle)); |
347 |
ept = Vec(conn.d, -conn.t/2) + node.r * eno; |
ept = Vec(conn.d, -conn.t) + node.r * eno; |
348 |
|
|
349 |
elli = Geom::symmellipse__point_norm(ept, eno); |
elli = Geom::symmellipse__point_norm(ept, eno); |
350 |
|
|
762 |
void compute_rtbl(int n) { |
void compute_rtbl(int n) { |
763 |
rtbl.resize(n + 1); |
rtbl.resize(n + 1); |
764 |
|
|
765 |
a0 = atan(0.5 * c.t / c.d); |
a0 = atan(c.t / c.d); |
766 |
|
|
767 |
for (int i = 1; i < n; i++) { |
for (int i = 1; i < n; i++) { |
768 |
float t = i * (1.0 / n); |
float t = i * (1.0 / n); |