import sys, os
from math import sin, cos, pi

# Add the igl library to the modules search path
import math

sys.path.insert(0, os.getcwd() + "/../")
import pyigl as igl

from shared import TUTORIAL_SHARED_PATH, check_dependencies, print_usage

dependencies = ["viewer"]
check_dependencies(dependencies)


def pre_draw(viewer):
    global recompute, anim_t, poses, C, BE, P, U, M, anim_t_dir

    if recompute:
        # Find pose interval
        begin = int(math.floor(anim_t)) % len(poses)
        end = int(math.floor(anim_t) + 1) % len(poses)
        t = anim_t - math.floor(anim_t)

        # Interpolate pose and identity
        anim_pose = igl.RotationList()
        for e in range(len(poses[begin])):
            anim_pose.append(poses[begin][e].slerp(t, poses[end][e]))

        # Propogate relative rotations via FK to retrieve absolute transformations
        vQ = igl.RotationList()
import sys, os

# Add the igl library to the modules search path
sys.path.insert(0, os.getcwd() + "/../")
import pyigl as igl

from shared import TUTORIAL_SHARED_PATH, check_dependencies

dependencies = ["viewer"]
check_dependencies(dependencies)

z_max = 1.0
z_dir = -0.03
k = 2
resolve = True

V = igl.eigen.MatrixXd()
U = igl.eigen.MatrixXd()

Z = igl.eigen.MatrixXd()

F = igl.eigen.MatrixXi()
b = igl.eigen.MatrixXi()

bc = igl.eigen.MatrixXd()


def pre_draw(viewer):
    global z_max, z_dir, k, resolve, V, U, Z, F, b, bc

    if resolve: