Operators¶
Every transformation operator (versor) you can add to a scene, together with its
visualization style class, the style parameters, and a static inline example.
Each example is rendered serverlessly via display_snapshot().
For the underlying data classes and algebra coverage, see operators.md under
the geometry section.
from typing import Any
import math
from pytanga.geometry import (
Dilator,
Direction,
GeneralRotor,
Inversion,
Motor,
Point,
ReflectionLine,
ReflectionPlane,
ReflectionPoint,
Rotor,
Translator,
)
from pytanga.viz import CameraConfig3d, ReflectionPlaneStyle, Visualizer
_NOTE = "You can interactively rotate, pan, and zoom this view."
def show(entity: Any, height: int = 340, **kwargs: Any) -> Any:
# Render a single operator in a fresh scene, inline and serverless.
viz = Visualizer(
title="Operators - " + type(entity).__name__,
add_default_axes=False,
annotation=_NOTE,
camera=CameraConfig3d(position=(2.5, 1.5, 3), target=(0, 0, 0)),
)
viz.add(entity, **kwargs)
return viz.display_snapshot(height=height)
ReflectionPlane¶
Reflection in a plane through the origin. Reflection is an alias.
| Field | Type | Description |
|---|---|---|
| color | str | CSS colour |
| opacity | float | 0-1 |
| extent | float | Drawn size in world units |
show(
ReflectionPlane(Direction(0, 0, 1)),
style=ReflectionPlaneStyle(extent=3.0),
)
ReflectionLine¶
Reflection about a line through the origin.
| Field | Type | Description |
|---|---|---|
| color | str | CSS colour |
| opacity | float | 0-1 |
| length | float | Drawn length in world units |
| thickness | float | Line width in screen pixels |
show(ReflectionLine(Direction(0, 0, 1)))
ReflectionPoint¶
Reflection about a point (point inversion through the given center).
ReflectionPointStyle is defined in pytanga.viz._styles but is not exported
from the top-level pytanga.viz namespace.
| Field | Type | Description |
|---|---|---|
| color | str | CSS colour |
| opacity | float | 0-1 |
| extent | float | Drawn size in world units |
show(ReflectionPoint(Point(0, 0, 0)))
Inversion¶
Inversion in a sphere centered at the origin.
| Field | Type | Description |
|---|---|---|
| color | str | CSS colour |
| opacity | float | 0-1 |
show(Inversion(Point(0, 0, 0)))
Rotor¶
A rotation (disc arc plus axis line).
| Field | Type | Description |
|---|---|---|
| color | str | CSS colour |
| opacity | float | 0-1 |
| disc_radius | float | Radius of the rotation disc |
show(Rotor(angle=math.pi / 2, axis=Direction(0, 0, 1)))
Translator¶
A translation (3D arrow).
| Field | Type | Description |
|---|---|---|
| color | str | CSS colour |
| opacity | float | 0-1 |
| length | float | Arrow length in world units |
show(Translator(vector=Direction(2, 0, 0)), color="#44aaff")
Dilator¶
A uniform scaling (concentric expanding rings).
| Field | Type | Description |
|---|---|---|
| color | str | CSS colour |
| opacity | float | 0-1 |
| ring_count | int | Number of concentric rings |
| max_radius | float | Radius of the outermost ring |
show(
Dilator(factor=2.0, origin=Point(0, 0, 0)),
color="#ffcc44",
)
Motor¶
A rigid body motion (screw): rotation about a displaced axis plus a translation along that axis. See the decomposition for the maths.
| Field | Type | Description |
|---|---|---|
| color | str | CSS colour |
| opacity | float | 0-1 |
show(
Motor(
rotor=Rotor(angle=math.pi / 2, axis=Direction(0, 0, 1)),
translator=Translator(vector=Direction(1, 1, 1)),
),
color="#ff66cc",
)
GeneralRotor¶
A rotation about an axis that does not pass through the origin.
| Field | Type | Description |
|---|---|---|
| color | str | CSS colour |
| opacity | float | 0-1 |
show(
GeneralRotor(
angle=0.5,
axis=Direction(0, 0, 1),
origin=Point(1, 0, 0),
),
)