mesh3d
pleat.intersecting_cylinders.mesh3d ¶
Interactive 3D preview of intersecting-cylinders models.
The :func:to_3d_mesh function builds a triangle mesh of the folded surface;
:func:show_3d returns a :mod:plotly figure suitable for interactive display
in Jupyter notebooks. plotly is an optional dependency installed via the
intersecting_cylinders extra.
Geometry¶
The 3D model is built on top of the ortho Conway operator applied to the
input tiling, with edge-midpoint vertices repositioned to the points where the
two dual circle packings touch (the same construction used in
show_dual_circle_packings in the docs notebook). Each ortho quad has cyclic
corners (v, t1, c, t2):
vis an original tiling vertex (a spike apex in 3D),cis the incenter of an adjacent face (a flat base point in 3D),t1, t2are the points where the original edges incident tovare tangent to both the face incircle (aroundc) and the vertex circle ofv.
The vertex-circle radius r_v = |v - t| controls the depth of the spike at
v. The model is split into half-triangles (c, v, t) and each half is
lifted using the profile's cross-section.
For r = 1 the half-triangle becomes one curved patch with a sharp apex at
v (depth -r_v * scale). For r < 1 the cylinder cross-section stays
self-similar but is rescaled: the curved patch occupies only the outer
fraction curved_extent = 1 - apex_inset of the v-c direction, and the
spike depth shrinks proportionally to -r_v * scale * curved_extent. The
missing apex is replaced by a flat cap at the original vertex:
- a curved trapezoid
{c, c_near_v, t_near_v, t}filling the outer portion of the half-triangle, withc, tatz = 0andc_near_v, t_near_vat the flat-tip depth-r_v * scale * curved_extent, and - a flat tip triangle
{v, c_near_v, t_near_v}at the same depth. Combined across all half-triangles incident tov, these triangles form the closed flat polygon that caps the (proportionally smaller) cylinder at the vertex.
Here c_near_v = v + apex_inset * (c - v) and t_near_v = v + apex_inset *
(t - v) -- both close to v. apex_inset = (1 - r) * sf / (1 - (1 - r) *
(1 - sf)) (zero for r = 1).
The curved trapezoid is lifted by interpreting the profile as a spike-depth
function read from the apex end inwards: zero depth and zero slope at the
c-t base (so neighbouring half-triangle patches meet smoothly across
c-t) and maximum slope toward the flat tip (so vertices look pointy).
See :func:_spike_depth_from_profile.
Sampling¶
Along the curved direction, the lift uses the profile's own
RDP-simplified sample points (which already concentrate samples near the
steep apex). When the profile has more than max_profile_samples points
they are uniformly subsampled in index space, always keeping the first and
last. Across the edge, the mesh uses n_across_edge uniform subdivisions
(the trapezoid is linear in that direction).
to_3d_mesh ¶
to_3d_mesh(
G: "EuclideanPositionHEG",
profile: Profile,
r: float = 1.0,
n_across_edge: int = 8,
max_profile_samples: int = 30,
) -> tuple[NDArray[np.float64], NDArray[np.int64]]
Build a triangle mesh of the folded intersecting-cylinders surface.
See the module docstring for the geometric construction. Each ortho quad
(v, t1, c, t2) is split along its v-c diagonal into two
half-triangles (c, v, t); each half-triangle is decomposed into a
curved trapezoid {c, c_near_v, t_near_v, t} filling the outer part
plus (for r < 1) a flat tip triangle {v, c_near_v, t_near_v} at
the vertex. The curved trapezoid is lifted using the profile's
cross-section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
'EuclideanPositionHEG'
|
Input tiling whose faces have well-defined (pseudo-)incenters. A working copy is taken; the input is not modified. |
required |
profile
|
Profile
|
Cross-section curve. |
required |
r
|
float
|
Triangle scaling matching :func: |
1.0
|
n_across_edge
|
int
|
Number of uniform subdivisions across each half-edge
(the |
8
|
max_profile_samples
|
int
|
Cap on the number of sample points used along the curved (spike-depth) direction. The profile's own RDP-simplified samples are used (so the resolution is highest where the curve is steepest); when there are more than this many, they are uniformly subsampled in index space, always keeping the first and last. |
30
|
Returns:
| Type | Description |
|---|---|
tuple[NDArray[float64], NDArray[int64]]
|
|
Source code in pleat/intersecting_cylinders/mesh3d.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
show_3d ¶
show_3d(
G: "EuclideanPositionHEG",
profile: Profile,
r: float = 1.0,
n_across_edge: int = 8,
max_profile_samples: int = 30,
color: str = "lightblue",
opacity: float = 1.0,
height: int = 600,
edge_color: str = "black",
edge_width: float = 2.0,
show_edges: bool = True,
) -> "Any"
Return an interactive plotly 3D figure of the folded model.
Requires :mod:plotly (pip install plotly or
pip install -e ".[intersecting_cylinders]").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
'EuclideanPositionHEG'
|
Input tiling. |
required |
profile
|
Profile
|
Cross-section curve. |
required |
r
|
float
|
Triangle scaling matching :func: |
1.0
|
n_across_edge
|
int
|
Mesh resolution across each edge (linear direction). |
8
|
max_profile_samples
|
int
|
Cap on the number of sample points along the
curved (spike-depth) direction; see :func: |
30
|
color
|
str
|
Surface colour. |
'lightblue'
|
opacity
|
float
|
Surface opacity in |
1.0
|
height
|
int
|
Figure height in pixels. |
600
|
edge_color
|
str
|
Colour of the sharp-fold polylines. |
'black'
|
edge_width
|
float
|
Line width of the sharp-fold polylines. |
2.0
|
show_edges
|
bool
|
When |
True
|
Returns:
| Type | Description |
|---|---|
'Any'
|
Plotly |
Source code in pleat/intersecting_cylinders/mesh3d.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | |