function [Q] = InverseRhino(TIP) % Assumes link 5 is pointing straight down Xtip = TIP(1); Ytip = TIP(2); Ztip = TIP(3) + 5; q1 = atan2(Ytip, Xtip) r = sqrt(Xtip^2 + Ytip ^ 2) z = TIP(3) + 5 d = sqrt(r^2 + (z-50)^2) h = sqrt(50^2 - (d/2)^2) qa = atan2(z-50,r); qb = atan2(h, d/2); q2 = -(qa + qb); q3 = pi - 2*atan2(d/2, h) q4 = -q2 - q3; Q = [q1 ; q2; q3; q4; 0]; end