picometer.shapes

Attributes

logger

Vector3

Versor3

zero3

Classes

AtomSet

Base class for protocol classes.

Shape

ExplicitShape

Helper class that provides a standard way to create an ABC using

Line

Helper class that provides a standard way to create an ABC using

Plane

Helper class that provides a standard way to create an ABC using

Functions

are_parallel(→ bool)

Check if input vectors point along the same line in any direction

are_synparallel(→ bool)

Check if input vectors point along the same line in the same direction

are_antiparallel(→ bool)

Check if input vectors point along the same line in opposite directions

are_perpendicular(→ bool)

Check in input vectors are perpendicular

versorize(→ Versor3)

Normalize and choose lexicographically-larger of antiparallel v and -v

degrees_between(→ float)

Calculate angle between two vectors in degrees

Module Contents

picometer.shapes.logger
picometer.shapes.Vector3
picometer.shapes.Versor3
picometer.shapes.zero3: Vector3
class picometer.shapes.AtomSet[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...
cart_xyz: numpy.ndarray
picometer.shapes.are_parallel(v: Vector3, w: Vector3) bool[source]

Check if input vectors point along the same line in any direction

picometer.shapes.are_synparallel(v: Vector3, w: Vector3) bool[source]

Check if input vectors point along the same line in the same direction

picometer.shapes.are_antiparallel(v: Vector3, w: Vector3) bool[source]

Check if input vectors point along the same line in opposite directions

picometer.shapes.are_perpendicular(v: Vector3, w: Vector3) bool[source]

Check in input vectors are perpendicular

picometer.shapes.versorize(v: Vector3) Versor3[source]

Normalize and choose lexicographically-larger of antiparallel v and -v

picometer.shapes.degrees_between(v: Vector3, w: Vector3, normalize: bool = False) float[source]

Calculate angle between two vectors in degrees

class picometer.shapes.Shape[source]
class Kind[source]

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

axial = 1
planar = 2
spatial = 3
kind: Shape.Kind
direction: Versor3
origin: Vector3
__repr__()[source]
at(origin: Vector3) Shape[source]

Return a copy of self with centroid at new origin

abstract _distance(other: Shape) float[source]
distance(other: Shape) float[source]

Delegated to a concrete implementation. Since self.kind >= other.kind, concrete implementations need only to handle shapes of equal of lower kind.

abstract _angle(other: Shape) float[source]
angle(*others: Shape) float[source]

Delegated to a concrete implementation. For Explicit shape, accept two parameters; for AtomSets, any size.

class picometer.shapes.ExplicitShape(direction: Vector3, origin: Vector3 = zero3)[source]

Bases: Shape, abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

property direction: Versor3
origin
_angle(*others: Shape) float[source]
class picometer.shapes.Line(direction: Vector3, origin: Vector3 = zero3)[source]

Bases: ExplicitShape

Helper class that provides a standard way to create an ABC using inheritance.

kind
_distance(other: Line)[source]
class picometer.shapes.Plane(direction: Vector3, origin: Vector3 = zero3)[source]

Bases: ExplicitShape

Helper class that provides a standard way to create an ABC using inheritance.

kind
_distance(other: Line | Plane) float[source]