Visualizing frames (rigid bodies)

10.3. Visualizing frames (rigid bodies)#

In the last sections, we only visualized points. The Player can also draw rigid bodies represented by homogeneous transform series (Nx4x4). For instance, let’s create two series of transforms that revolve around the x and z axes:

import numpy as np
import kineticstoolkit.lab as ktk

# Create a TimeSeries with two rotating transforms
transforms = ktk.TimeSeries(time=np.linspace(0, 5, 100))

transforms.data["RotationAroundX"] = ktk.geometry.create_transform_series(
    angles=np.linspace(0, 2 * np.pi, 100),
    positions=[[0.2, 0.0, 0.0]],
    seq="x",
)

transforms.data["RotationAroundZ"] = ktk.geometry.create_transform_series(
    angles=np.linspace(0, 2 * np.pi, 100),
    positions=[[0.0, 0.0, 0.2]],
    seq="z",
)

# Show these frames in the Player
p = ktk.Player(transforms)