@name Chaqua IKS Leg
@inputs [B F]:entity

interval(100)

if(first())
{
    function ikS(Dist,I1,I2,Src:vector,End:vector)
    {
        local D = Src-End
        local L = min(D:length(),Dist)
        local A1 = D:toAngle()
        local A2 = ang(-asin(L/Dist),0,0)
        holoAng(I1,A1+A2)
        holoAng(I2,A1-A2)
    }
    
    holoCreate(1, B:toWorld(vec()), vec(1), B:toWorld(ang()))
    holoCreate(2, B:toWorld(vec(0, 0, 125)), vec(1), B:toWorld(ang()))
    holoCreate(3, B:toWorld(vec()), vec(1), B:toWorld(ang()))
    
    holoParent(1, B)
    holoParent(2, 1)
    holoParent(3, 2)
    
    holoCreate(4, B:toWorld(vec(0, 0, 62.5)), vec(1, 1, 62.5/6), B:toWorld(ang()))
    holoCreate(5, B:toWorld(vec(0, 0, 62.5)), vec(1, 1, 62.5/6), B:toWorld(ang()))
    
    holoParent(4, 1)
    holoParent(5, 2)
}

ikS(250, 1, 2, B:pos(), F:pos())
