140 |
* XXX Z calculation needs thinking. |
* XXX Z calculation needs thinking. |
141 |
*/ |
*/ |
142 |
ZVec projectToConnLine(ZVec v) const { |
ZVec projectToConnLine(ZVec v) const { |
|
float l = dir.dot(v - node.ctr); |
|
143 |
v = v - norm.dot(v-node.ctr) * norm; |
v = v - norm.dot(v-node.ctr) * norm; |
144 |
#if 0 |
#if 0 |
145 |
if(dir.dot(v-node.ctr) <= node.r) { |
if(dir.dot(v-node.ctr) <= node.r) { |
146 |
v = v - dir.dot(v-node.ctr) * dir; |
v = v - dir.dot(v-node.ctr) * dir; |
147 |
} |
} |
148 |
#endif |
#endif |
149 |
float f = (l - node.r) / (d - node.r); |
v.z = depth(v); |
|
if (d <= node.r) |
|
|
v.z = node.ctr.z; |
|
|
else if (f >= 1) |
|
|
v.z = z; |
|
|
else if (f >= 0) |
|
|
v.z = lerp(node.ctr.z, z, f); |
|
|
else |
|
|
v.z = node.ctr.z; |
|
150 |
return v; |
return v; |
151 |
} |
} |
152 |
|
|
153 |
|
float depth(Vec v) const { |
154 |
|
float l = dir.dot(v - node.ctr); |
155 |
|
//float l = (v - node.ctr).length(); |
156 |
|
float f = (l - node.r) / (d - node.r); |
157 |
|
if (d > node.r) |
158 |
|
if (f >= 1) |
159 |
|
return z; |
160 |
|
else if (f >= 0) |
161 |
|
return lerp(node.ctr.z, z, f); |
162 |
|
return node.ctr.z; |
163 |
|
} |
164 |
|
|
165 |
}; |
}; |
166 |
|
|
167 |
/** A nonlinearly stretched circle fillet (test). |
/** A nonlinearly stretched circle fillet (test). |
216 |
ZVec pt = node.ctr + xn * conn.dir + y * conn.norm; |
ZVec pt = node.ctr + xn * conn.dir + y * conn.norm; |
217 |
|
|
218 |
ZVec proj = conn.projectToConnLine(pt); |
ZVec proj = conn.projectToConnLine(pt); |
219 |
pt.z = proj.z; |
//pt.z = proj.z; |
220 |
|
pt.z = conn.depth(pt); |
221 |
if(intern) { |
if(intern) { |
222 |
//if(fract > .94) |
//if(fract > .94) |
223 |
// *intern = node.ctr; |
// *intern = node.ctr; |
562 |
ZVec p2 = other.point(Vec(p-main.node.ctr).normalized(), success); |
ZVec p2 = other.point(Vec(p-main.node.ctr).normalized(), success); |
563 |
ZVec res; |
ZVec res; |
564 |
if(success) { |
if(success) { |
565 |
ZVec edgep = .5 *(p + p2 - 2 * main.node.ctr); |
Vec edgep = p + p2 - 2 * main.node.ctr; |
566 |
edgep *= main.node.r / edgep.xylength(); |
edgep *= main.node.r / edgep.length(); |
567 |
edgep += main.node.ctr; |
res = p + p2 - main.node.ctr - edgep; |
|
res = p + p2 - edgep; |
|
568 |
} else { |
} else { |
569 |
res = p; |
res = p; |
570 |
} |
} |
630 |
v1(node.ctr + node.r * dirVec(aend)) { |
v1(node.ctr + node.r * dirVec(aend)) { |
631 |
} |
} |
632 |
CircularSliceSpan(const CircularNode &node, |
CircularSliceSpan(const CircularNode &node, |
633 |
Vec vstart, Vec vend) : |
Vec vstart, Vec vend, int mode = 0) : |
634 |
node(node), |
node(node), |
635 |
v0(vstart.x, vstart.y, node.ctr.z), |
v0(vstart.x, vstart.y, node.ctr.z), |
636 |
v1(vend.x, vend.y, node.ctr.z) { |
v1(vend.x, vend.y, node.ctr.z) { |
638 |
|
|
639 |
ZVec point(float fract, ZVec *intern = 0) const { |
ZVec point(float fract, ZVec *intern = 0) const { |
640 |
if(intern) *intern = node.ctr - ZVec(0,0,20); |
if(intern) *intern = node.ctr - ZVec(0,0,20); |
641 |
return lerp(v0, v1, fract); |
return lerp(v0, v1, fract);; |
642 |
} |
} |
643 |
|
|
644 |
}; |
}; |