{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "blend shape:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "np_file_path = r'../records/2023-12-23-17-19-54.npy'\n",
    "bs = np.load(np_file_path, allow_pickle=True)\n",
    "print(bs.shape)\n",
    "# draw lines from bs\n",
    "for i in range(bs.shape[1]):\n",
    "    line_data = bs[:120]\n",
    "    plt.plot(line_data)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "旋转测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "新的旋转四元数： [0 1 0 0]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "# 原始的旋转四元数\n",
    "x3, y3, z3, w3 = (0, 0, 0, 1)\n",
    "\n",
    "# 180度绕 Y 轴的四元数表示\n",
    "r = np.array([0, 1, 0, 0])\n",
    "\n",
    "# 四元数乘法函数\n",
    "def quat_multiply(q1, q2):\n",
    "    x1, y1, z1, w1 = q1\n",
    "    x2, y2, z2, w2 = q2\n",
    "    \n",
    "    w = w1*w2 - x1*x2 - y1*y2 - z1*z2\n",
    "    x = x1*w2 + w1*x2 + y1*z2 - z1*y2\n",
    "    y = w1*y2 - x1*z2 + y1*w2 + z1*x2\n",
    "    z = w1*z2 + x1*y2 - y1*x2 + z1*w2\n",
    "    \n",
    "    return np.array([x, y, z, w])\n",
    "\n",
    "# 现在找到新的旋转四元数表示\n",
    "new_quaternion = quat_multiply(r, [x3, y3, z3, w3])\n",
    "\n",
    "print(\"新的旋转四元数：\", new_quaternion)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "合并文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1270, 61)\n",
      "(1253, 61)\n",
      "(2523, 61)\n"
     ]
    }
   ],
   "source": [
    "#读取 tmp_cn.npy tmp_en.npy\n",
    "import numpy as np\n",
    "bs1 = np.load(r'../tmp_cn.npy', allow_pickle=True)\n",
    "bs2 = np.load(r'../tmp_en.npy', allow_pickle=True)\n",
    "print(bs1.shape)\n",
    "print(bs2.shape)\n",
    "# 在维度0上合并\n",
    "bs = np.concatenate((bs1, bs2), axis=0)\n",
    "print(bs.shape)\n",
    "#保存维度0的前1500个数值\n",
    "# np.save(r'../tmp_16.npy', bs)\n",
    "np.save(r'../tmp_16.npy', bs[:1500])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
