atomlib.transform
IntoTransform3D
module-attribute
IntoTransform3D: TypeAlias = Union[
"Transform3D",
Callable[[NDArray[floating]], ndarray],
ndarray,
]
Type which is coercable into a Transform3D
.
Includes transformations, numpy arrays (3x3 or 4x4), and functions (which should take a Nx3 ndarray and return an ndarray of the same shape).
Transform3D
Bases: ABC
Arbitrary 3D transformation. Superclass of all 3D transformation types.
Transformations can be composed: t3 = t1 @ t2
, or applied
to points: transformed = transform @ points
using the @
operator.
Alternatively, points can be transformed using functional notation:
transformed = transform(points)
.
Source code in atomlib/transform.py
identity
abstractmethod
staticmethod
identity() -> Transform3D
make
staticmethod
make(data: IntoTransform3D) -> Transform3D
Make a transformation from a function or numpy array (3x3 or 4x4).
Source code in atomlib/transform.py
compose
abstractmethod
compose(other: Transform3D) -> Transform3D
transform
abstractmethod
transform_vec
Transform vector quantities. This excludes translation, as would be expected when transforming vectors.
Source code in atomlib/transform.py
FuncTransform3D
Bases: Transform3D
Transformation which applies a function to the given points.
Source code in atomlib/transform.py
make
staticmethod
make(data: IntoTransform3D) -> Transform3D
Make a transformation from a function or numpy array (3x3 or 4x4).
Source code in atomlib/transform.py
transform_vec
Transform vector quantities. This excludes translation, as would be expected when transforming vectors.
Source code in atomlib/transform.py
identity
staticmethod
identity() -> FuncTransform3D
transform
Transform points according to the given transformation.
Source code in atomlib/transform.py
compose
compose(other: Transform3D) -> FuncTransform3D
AffineTransform3D
Bases: Transform3D
Source code in atomlib/transform.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 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 |
|
make
staticmethod
make(data: IntoTransform3D) -> Transform3D
Make a transformation from a function or numpy array (3x3 or 4x4).
Source code in atomlib/transform.py
identity
staticmethod
identity() -> AffineTransform3D
round_near_zero
from_linear
staticmethod
from_linear(linear: LinearTransform3D) -> AffineTransform3D
Make an affine transformation from a linear transformation.
Source code in atomlib/transform.py
to_linear
to_linear() -> LinearTransform3D
to_translation
to_translation() -> AffineTransform3D
det
det() -> float
translation
translation() -> ndarray
inverse
inverse() -> AffineTransform3D
Return the inverse of an affine transformation.
Source code in atomlib/transform.py
translate
translate(x: VecLike) -> AffineTransform3D
translate(
x: Num = 0.0, y: Num = 0.0, z: Num = 0.0
) -> AffineTransform3D
Create or append an affine translation.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
scale
scale(x: VecLike) -> AffineTransform3D
scale(
x: Num = 1.0,
y: Num = 1.0,
z: Num = 1.0,
*,
all: Num = 1.0
) -> AffineTransform3D
scale(
x: Union[Num, VecLike] = 1.0,
y: Num = 1.0,
z: Num = 1.0,
*,
all: Num = 1.0
) -> AffineTransform3D
Create or append a scaling transformation.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
rotate
rotate(v: VecLike, theta: Num) -> AffineTransform3D
Create or append a rotation transformation of theta
radians CCW around the given vector v
.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
rotate_euler
rotate_euler(
x: Num = 0.0, y: Num = 0.0, z: Num = 0.0
) -> AffineTransform3D
Create or append a Euler rotation transformation. Rotation is performed on the x axis first, then y axis and z axis. Values are specified in radians.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
mirror
mirror(a: VecLike) -> AffineTransform3D
mirror(a: Num, b: Num, c: Num) -> AffineTransform3D
mirror(
a: Union[Num, VecLike],
b: Optional[Num] = None,
c: Optional[Num] = None,
) -> AffineTransform3D
Create or append a mirror transformation across the given plane.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
strain
strain(
strain: float,
v: VecLike = (0, 0, 1),
poisson: float = 0.0,
) -> AffineTransform3D
Apply a strain of strain
in direction v
, assuming an elastically isotropic material.
Strain is applied relative to the origin.
With poisson=0
(default), a uniaxial strain is applied.
With poisson=-1
, hydrostatic strain is applied.
Otherwise, a uniaxial stress is applied for a material with Poisson ratio poisson
,
which results in shrinkage perpendicular to the direction strain is applied.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
align_standard
align_standard() -> AffineTransform3D
Align self
so v1
is in the x-axis and v2
is in the xy-plane.
This is equivalent to a \(QR\) decomposition which keeps only the right-triangular matrix \(R\).
For an affine transformation, this rotates the transformation around the global origin (including any transformation).
Source code in atomlib/transform.py
transform
Transform points according to the given transformation.
Source code in atomlib/transform.py
transform_vec
compose
compose(other: AffineTransform3D) -> AffineTransform3D
compose(other: Transform3D) -> Transform3D
Compose this transformation with another.
Source code in atomlib/transform.py
conjugate
conjugate(
transform: AffineTransform3D,
) -> AffineTransform3D
conjugate(transform: Transform3D) -> Transform3D
Apply transform
in the coordinate frame of self
.
Equivalent to an (inverse) conjugation in group theory, or :math:T^-1 A T
Source code in atomlib/transform.py
LinearTransform3D
Bases: AffineTransform3D
Source code in atomlib/transform.py
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 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 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 |
|
make
staticmethod
make(data: IntoTransform3D) -> Transform3D
Make a transformation from a function or numpy array (3x3 or 4x4).
Source code in atomlib/transform.py
transform_vec
round_near_zero
from_linear
staticmethod
from_linear(linear: LinearTransform3D) -> AffineTransform3D
Make an affine transformation from a linear transformation.
Source code in atomlib/transform.py
to_translation
to_translation() -> AffineTransform3D
translate
translate(x: VecLike) -> AffineTransform3D
translate(
x: Num = 0.0, y: Num = 0.0, z: Num = 0.0
) -> AffineTransform3D
Create or append an affine translation.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
translation
identity
staticmethod
identity() -> LinearTransform3D
det
det() -> float
inverse
inverse() -> LinearTransform3D
to_linear
to_linear() -> LinearTransform3D
is_diagonal
Return whether this transformation is diagonal (i.e. axis-aligned scaling only).
Source code in atomlib/transform.py
is_normal
Returns True
if self
is a normal matrix.
is_orthogonal
Returns True
if self
is an orthogonal matrix (i.e. a pure rotation or roto-reflection).
is_scaled_orthogonal
Returns True
if self
is a scaled orthogonal matrix (composed of orthogonal
basis vectors, i.e. a scaling + a rotation or roto-reflection)
Source code in atomlib/transform.py
mirror
mirror(a: VecLike) -> LinearTransform3D
mirror(a: Num, b: Num, c: Num) -> LinearTransform3D
mirror(
a: Union[Num, VecLike],
b: Optional[Num] = None,
c: Optional[Num] = None,
) -> LinearTransform3D
Create or append a mirror transformation across the given plane.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
strain
strain(
strain: float,
v: VecLike = (0, 0, 1),
poisson: float = 0.0,
) -> LinearTransform3D
Apply a strain of strain
in direction v
, assuming an elastically isotropic material.
Strain is applied relative to the origin.
With poisson=0
(default), a uniaxial strain is applied.
With poisson=-1
, hydrostatic strain is applied.
Otherwise, a uniaxial stress is applied for a material with Poisson ratio poisson
,
which results in shrinkage perpendicular to the direction strain is applied.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
rotate
rotate(v: VecLike, theta: Num) -> LinearTransform3D
Create or append a rotation transformation of theta
radians CCW around the given vector v
.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
rotate_euler
rotate_euler(
x: Num = 0.0, y: Num = 0.0, z: Num = 0.0
) -> LinearTransform3D
Create or append a Euler rotation transformation. Rotation is performed on the x axis first, then y axis and z axis. Values are specified in radians.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
align
align(
v1: VecLike, horz: Optional[VecLike] = None
) -> LinearTransform3D
Create a transformation which transforms v1
to align with [0, 0, 1].
If horz
is specified, it will be aligned in the direction of [1, 0, 0].
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
align_to
align_to(
v1: VecLike,
v2: VecLike,
p1: Literal[None] = None,
p2: Literal[None] = None,
) -> LinearTransform3D
align_to(
v1: VecLike, v2: VecLike, p1: VecLike, p2: VecLike
) -> LinearTransform3D
align_to(
v1: VecLike,
v2: VecLike,
p1: Optional[VecLike] = None,
p2: Optional[VecLike] = None,
) -> LinearTransform3D
Create a transformation which transforms v1
to align with v2
.
If specified, additionally ensure that p1
aligns with p2
in the plane of v2
.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
align_standard
align_standard() -> LinearTransform3D
Align self
so v1
is in the x-axis and v2
is in the xy-plane.
This is equivalent to a \(QR\) decomposition which keeps only the right-triangular matrix \(R\).
Source code in atomlib/transform.py
scale
scale(x: VecLike) -> LinearTransform3D
scale(
x: Num = 1.0,
y: Num = 1.0,
z: Num = 1.0,
*,
all: Num = 1.0
) -> LinearTransform3D
scale(
x: Union[Num, VecLike] = 1.0,
y: Num = 1.0,
z: Num = 1.0,
*,
all: Num = 1.0
) -> LinearTransform3D
Create or append a scaling transformation.
Can be called as a classmethod or instance method.
Source code in atomlib/transform.py
conjugate
Apply transform
in the coordinate frame of self
.
Equivalent to an (inverse) conjugation in group theory, or \(T^{-1} A T\)
Source code in atomlib/transform.py
compose
Compose this transformation with another.
Source code in atomlib/transform.py
transform
Transform points according to the given transformation.