Disabled external gits

This commit is contained in:
2022-04-07 18:46:57 +02:00
parent 88cb3426ad
commit 15e7120d6d
5316 changed files with 4563444 additions and 6 deletions

View File

@@ -0,0 +1,311 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import meshplot as mp\n",
"import numpy as np\n",
"import sys\n",
"import json\n",
"from matplotlib import pyplot as plt\n",
"sys.path.append(\"../src/\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1. Load OBJ model"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"with open('../data/gym.json', 'r') as infile:\n",
" [V, F] = json.load(infile)\n",
" V = np.array(V)\n",
" F = np.array(F)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2. Mesh Plotting"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"def draw_mesh(V, F):\n",
" shading = {\"flat\":True, # Flat or smooth shading of triangles\n",
" \"wireframe\":True, \"wire_width\": 0.03, \"wire_color\": \"black\", # Wireframe rendering\n",
" \"width\": 600, \"height\": 600, # Size of the viewer canvas\n",
" \"antialias\": True, # Antialising, might not work on all GPUs\n",
" \"scale\": 2.0, # Scaling of the model\n",
" \"side\": \"DoubleSide\", # FrontSide, BackSide or DoubleSide rendering of the triangles\n",
" \"colormap\": \"viridis\", \"normalize\": [None, None], # Colormap and normalization for colors\n",
" \"background\": \"#ffffff\", # Background color of the canvas\n",
" \"line_width\": 1.0, \"line_color\": \"black\", # Line properties of overlay lines\n",
" \"bbox\": False, # Enable plotting of bounding box\n",
" \"point_color\": \"red\", \"point_size\": 0.01 # Point properties of overlay points\n",
" }\n",
" #p = mp.plot(V, F, shading=shading, return_plot=True)\n",
" mp.plot(V, F)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/sora/.local/lib/python3.9/site-packages/jupyter_client/session.py:716: UserWarning: Message serialization failed with:\n",
"Out of range float values are not JSON compliant\n",
"Supporting this message is deprecated in jupyter-client 7, please make sure your message is JSON-compliant\n",
" content = self.pack(content)\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c463e93a5b0044fbba0746c52a887176",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.5660395…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"draw_mesh(V, F)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 3. Mesh Centroid Plotting"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"from geometry import compute_mesh_centroid\n",
"def draw_mesh_with_centroid(V, F):\n",
" shading = {\"flat\":True, # Flat or smooth shading of triangles\n",
" \"wireframe\":True, \"wire_width\": 0.03, \"wire_color\": \"black\", # Wireframe rendering\n",
" \"width\": 600, \"height\": 600, # Size of the viewer canvas\n",
" \"antialias\": True, # Antialising, might not work on all GPUs\n",
" \"scale\": 2.0, # Scaling of the model\n",
" \"side\": \"DoubleSide\", # FrontSide, BackSide or DoubleSide rendering of the triangles\n",
" \"colormap\": \"viridis\", \"normalize\": [None, None], # Colormap and normalization for colors\n",
" \"background\": \"#ffffff\", # Background color of the canvas\n",
" \"line_width\": 1.0, \"line_color\": \"black\", # Line properties of overlay lines\n",
" \"bbox\": False, # Enable plotting of bounding box\n",
" \"point_color\": \"red\", \"point_size\": 0.01 # Point properties of overlay points\n",
" }\n",
" mesh_plot = mp.plot(V, F, shading=shading, return_plot=True)\n",
" center0 = np.array(compute_mesh_centroid(V, F))\n",
" center1 = center0.copy()\n",
" center1[1] = 0\n",
" vertices = np.vstack([center0, center1])\n",
" mesh_plot.add_points(vertices, shading={\"point_color\": \"black\", \"point_size\": 0.1})\n",
" mesh_plot.add_edges(vertices, np.array([[0, 1]]), shading={\"line_color\": \"black\", \"line_width\" : 0.5});"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4f0181b991864ebe91e419ff21dbb932",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.5660395…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.70220297 0.14449098 0. ]\n"
]
}
],
"source": [
"draw_mesh_with_centroid(V, F)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 4. Shearing Transformation"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
"import ipywidgets as widgets\n",
"from shear import shear_transformation\n",
"def draw_mesh_after_shear_transformation(V, F, nu):\n",
" V1 = shear_transformation(V, nu)\n",
" draw_mesh_with_centroid(V1, F)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "29b3847a9adc46aab07c80e2d794a69c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.0, description='nu', max=1.0, min=-1.0), Output()), _dom_classes=('w…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"interact(draw_mesh_after_shear_transformation, V = fixed(V), F = fixed(F), nu = (-1, 1, 0.1));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 5. Shear Equilibrium"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"from shear import shear_equilibrium\n",
"from geometry import compute_center_support_line\n",
"def compute_equilibrium_mesh(V, F):\n",
" x_csl = compute_center_support_line(V)\n",
" V1 = shear_equilibrium(V, F, x_csl)\n",
" draw_mesh_with_centroid(V1, F)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Copy the following codes and find equilibrium shapes for all other examples in ../data folder "
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1a828dcd3277486da42e79e5865c4917",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.5046897…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.63531671 0.39031879 0. ]\n"
]
}
],
"source": [
"with open('../data/dinosaur.json', 'r') as infile:\n",
" [V, F] = json.load(infile)\n",
" V = np.array(V)\n",
" F = np.array(F)\n",
" compute_equilibrium_mesh(V, F)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "gc_course_env",
"language": "python",
"name": "gc_course_env"
},
"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.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}