Shapes¶
Factory class providing predefined DNA shape control points.
mdna.utils.Shapes
¶
Factory for parametric 3-D curves used as DNA path control points.
Each class method returns an (n, 3) array of points tracing a named
shape that can be passed directly to :class:~mdna.SplineFrames.
Source code in mdna/utils.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 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 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 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 | |
__init__(parametric_function, t_values=None, num_points=100)
¶
Initialize a Shapes instance from a parametric function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parametric_function
|
callable
|
|
required |
t_values
|
ndarray
|
Parameter values. |
None
|
num_points
|
int
|
Number of sample points. |
100
|
Source code in mdna/utils.py
bonus(t_values=None, num_points=100)
classmethod
¶
Create a bonus (Batman) shape.
Credit: https://www.geogebra.org/m/pH8wD3rW, Author: Simona Riva.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t_values
|
ndarray
|
Parameter values. |
None
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the bonus shape, shape |
Source code in mdna/utils.py
circle(radius=1, t_values=None, num_points=100)
classmethod
¶
Create a circle in 3D space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Radius of the circle. |
1
|
t_values
|
ndarray
|
Parameter values; defaults
to |
None
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the circle, shape |
Source code in mdna/utils.py
ellipse(a=1, b=1, t_values=None, num_points=100)
classmethod
¶
Create an ellipse in the xy-plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Semi-major axis (x). |
1
|
b
|
float
|
Semi-minor axis (y). |
1
|
t_values
|
ndarray
|
Parameter values. |
None
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the ellipse, shape |
Source code in mdna/utils.py
heart(a=1, b=1, c=1, t_values=None, num_points=100)
classmethod
¶
Create a heart-shaped curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Amplitude of the x-component. |
1
|
b
|
float
|
Amplitude of the first cosine term. |
1
|
c
|
float
|
Amplitude of the second cosine term. |
1
|
t_values
|
ndarray
|
Parameter values. |
None
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the heart shape, shape |
Source code in mdna/utils.py
helix(radius=1, pitch=1, height=1, num_turns=1, num_points=100)
classmethod
¶
Create a helical curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Helix radius. |
1
|
pitch
|
float
|
Pitch factor (rise per turn). |
1
|
height
|
float
|
Overall height scaling. |
1
|
num_turns
|
int
|
Number of helical turns. |
1
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the helix, shape |
Source code in mdna/utils.py
lemniscate_of_bernoulli(a=1, b=1, t_values=None, num_points=100)
classmethod
¶
Create a lemniscate of Bernoulli (figure-eight curve).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
x-scaling factor. |
1
|
b
|
float
|
y-scaling factor. |
1
|
t_values
|
ndarray
|
Parameter values. |
None
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the lemniscate, shape |
Source code in mdna/utils.py
line(length=1, num_points=100)
classmethod
¶
Create a straight line along the x-axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Length of the line. |
1
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the line, shape |
Source code in mdna/utils.py
mobius_strip(radius=1, width=0.5, num_twists=1, t_values=None, num_points=100)
classmethod
¶
Create a Möbius strip centre-line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Major radius of the strip. |
1
|
width
|
float
|
Half-width of the strip. |
0.5
|
num_twists
|
int
|
Number of half-twists. |
1
|
t_values
|
ndarray
|
Parameter values. |
None
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the Möbius strip, shape |
Source code in mdna/utils.py
spiral(radius=1, pitch=1, height=1, num_turns=1, num_points=100)
classmethod
¶
Create an expanding spiral (radius grows with t).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Initial radius scaling. |
1
|
pitch
|
float
|
Pitch factor. |
1
|
height
|
float
|
Height scaling. |
1
|
num_turns
|
int
|
Number of turns. |
1
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the spiral, shape |
Source code in mdna/utils.py
square(side=1, t_values=None, num_points=100)
classmethod
¶
Create a square path (segment-wise construction).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
side
|
float
|
Length of each side. |
1
|
t_values
|
ndarray
|
Parameter values. |
None
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the square, shape |
Source code in mdna/utils.py
torus_helix(R=1, r=2, num_windings=3, t_values=None, num_points=100)
classmethod
¶
Create a helix wound around a torus.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
R
|
float
|
Major radius of the torus. |
1
|
r
|
float
|
Minor radius (tube radius). |
2
|
num_windings
|
int
|
Number of windings around the torus. |
3
|
t_values
|
ndarray
|
Parameter values. |
None
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the torus helix, shape |
Source code in mdna/utils.py
trefoil(radius=1, num_turns=1, t_values=None, num_points=100)
classmethod
¶
Create a trefoil knot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Scaling factor. |
1
|
num_turns
|
int
|
Number of traversals around the knot. |
1
|
t_values
|
ndarray
|
Parameter values. |
None
|
num_points
|
int
|
Number of sample points. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
points |
ndarray
|
Points on the trefoil knot, shape |