Skip to content

Instantly share code, notes, and snippets.

View shrinktofit's full-sized avatar

Leslie Leigh (李的序) shrinktofit

View GitHub Profile
@shrinktofit
shrinktofit / DownloadMixamoByJakeCattrall.js
Created September 15, 2023 08:27 — forked from krazyjakee/DownloadMixamoByJakeCattrall.js
Downloads all the free Mixamo Animations
function trigger(el, eventType) {
if (typeof eventType === 'string' && typeof el[eventType] === 'function') {
el[eventType]();
} else {
const event =
eventType === 'string'
? new Event(eventType, {bubbles: true})
: eventType;
el.dispatchEvent(event);
}

Let $N$ to be normal of plane decided by $a$ and $b$, where $N$ is at the side so that it has the minimal angle between the input normal. Let $angle$ be the unsigned angle between $a$ and $b$. Around $N$, following the right hand rule, if $a$ can rotate to $b$ in positive $angle$ angle, then the result is $angle$. Otherwise, the result is $-angle$.

@shrinktofit
shrinktofit / inverse_transform.md
Last active May 18, 2023 08:21
inverse transform

Let $b$ be the inverse of $a$, then for the translation term $T$(Vector), rotation term $Q$(Quaternion), scale term $S$(Vector):

$$\begin{equation} \begin{split} T_(a * b) & = T_b + (Q_b \times (S_b \times T_a) \times Q_b^{-1}) = 0 \\\ T(b) & = -(Q_b \times S_b \times T_a \times Q_b^{-1}) \\\ & = Q_b \times (S_b \times -T_a) \times Q_b^{-1} \end{split} \end{equation}$$
@shrinktofit
shrinktofit / EnhancedApplyScale.py
Created May 3, 2023 07:23
Blender 增强版的应用缩放
import bpy
def print(data):
for window in bpy.context.window_manager.windows:
screen = window.screen
for area in screen.areas:
if area.type == 'CONSOLE':
override = {'window': window, 'screen': screen, 'area': area}
bpy.ops.console.scrollback_append(override, text=str(data), type="OUTPUT")
@shrinktofit
shrinktofit / TwoBoneIK.ts
Created August 25, 2022 06:40
Cocos Creator Two Bone IK
import { clamp, Node, NodeSpace, Quat, Vec3 } from "cc";
/**
* 解析双骨骼(三关节)的 IK 问题。
* 三关节分别称为根关节、中间关节和末端关节。例如,分别对应于大腿、膝盖和脚关节。
* @param root 根关节。
* @param middle 中间关节。
* @param end 末端关节。
* @param target 末端关节要抵达的目标位置(世界空间)。
* @param hint 中间关节的提示位置(世界空间),用于决定中间关节的朝向。
@shrinktofit
shrinktofit / TwoBoneIK.ts
Created August 17, 2022 05:48
Cocos Creator Two Bone IK
export function solveTwoBoneIK(
a: Node,
b: Node,
c: Node,
target: Vec3,
) {
const sanityChecker = new TwoBoneIKNodeSanityChecker(a, b, c);
const pA = Vec3.clone(a.worldPosition);
const pB = Vec3.clone(b.worldPosition);
@shrinktofit
shrinktofit / index.md
Last active August 10, 2022 04:12
Animation: distinguish bone nodes

Abstract

In our engine, bones exist in form of scene node. We can't tell if a node denotes a bone or not. This sometimes becomes obstacle in animation system.

Problem Statement

Obstacles

Why do we need to distinguish bone nodes from normal? I'll list some cases.

@shrinktofit
shrinktofit / index.tex
Last active April 20, 2022 10:29
Calculate world position, rotation and scale
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{document}
Let RS(denoted as $R$) be "rotation then scale". \\
RS then translation(denoted as $t$):
@shrinktofit
shrinktofit / index.md
Last active November 30, 2021 07:23
线性混合多个指定了权重的值,不要遍历两遍计算出权重的和

image

也就是说,下面两种算法是等价的,我们不需要遍历两遍:

// 预先累加权重和
function blend(samples: ReadonlyArray<readonly [value: number, weight: number]>) {
  let result = 0.0;
  let sumWeights = 0.0;
  for (const [v, w] of samples) {
@shrinktofit
shrinktofit / words.md
Last active November 8, 2021 10:44
今天又学会了几个单词
  • elementary

  • rudimentary

  • feasible

  • viable

  • impair

  • interconnect