Table of Contents
Simple 2-Joint Inverse Kinematic With Isosceles Triangle
Math Formula
Formula to get height of isosceles triangle from one side and base , you can use it to find the elbow position.
TypeScript version.
function getHeight(a: number, b: number){
return Math.sqrt((a ** 2) - ((b ** 2) / 4));
}
Application
Let’s say you have shoulder , hand , and is half length of your arm. You want to find where the elbow position is.
TypeScript version (vector library using vecti).
import { Vector } from "vecti";
const p1 = new Vector(10, 10);
const p2 = new Vector(150, 150);
const a = 100;
const b = p2.subtract(p1).length();
const c = p2.subtract(p1).normalize();
const d = c.multiply(getHeight(a, b));
const k = p1.add(c.multiply(b / 2)).add(d.rotateByDegrees(90)); // because SVG and Canvas using top to bottom you can use -90, you can also use this to switch direction