Braço com 2 revolute joints

Algoritmo de Inverse Kinematics para um braço robótico com 2 revolute joints

$s1 = this.arm.seg01;
$s2 = this.arm.seg01.seg02;

pit = function($x,$y) {
	h = Math.pow($x,2) + Math.pow($y,2);
	h = Math.pow(h,0.5);
	return h
}

$m=150
$n=150

onMouseMove = function() {
	$e = arm._xmouse<0;
	$f = 1-2*$e;
	$g = $e*Math.PI;
	$h = pit(arm._xmouse,arm._ymouse);

	$x = arm._xmouse*Math.min($m+$n,$h)/$h;
	$y = arm._ymouse*Math.min($m+$n,$h)/$h;

	$a = $y/$x;
	$b = ($x*$x+$y*$y)/(2*$m*$n)-($m/$n+$n/$m)/2;
	$c = $n*Math.sin(Math.acos($b))/($m+$n*$b);

	$r2 = Math.acos($b);
	$r1 = -Math.atan($c)+Math.atan($a)-$g;

	$s1._rotation = $r1/Math.PI*180;
	$s2._rotation = $r2/Math.PI*180;

	trace([$s1._rotation,$s2._rotation]);
}

gramUpper

Função em VBA para substituir PRI.MAIÚSCULA do Excel, incluindo Lowercase em pronomes e Uppercase em palavras que contenham apenas consoantes e siglas conhecidas.

Function inArray(x, a) As Long
    inArray = False
    For Each i In a
        If UCase(x) = UCase(i) Then inArray = True
    Next i
End Function

Function isPronoun(word)
    pronouns = Array("E", "Da", "Do", "Das", "Dos", "De", "Em", "Para", "Com", "Sobre", "A", "O", "As", "Os", "Na", "No", "Nas", "Nos", "Desde", "Sem")
    isPronoun = inArray(word, pronouns)
End Function

Function isAcronym(word)
    vowels = Array("a", "e", "i", "o", "u")
    acronyms = Array("E&P", "CO2", "PRAVAP")
    isAcronym = True
    If inArray(word, acronyms) = False Then
        For i = 1 To Len(word)
            x = Mid(word, i, 1)
            If inArray(x, vowels) Then isAcronym = False
        Next i
    End If
End Function

Function gramUpper(txt As String) As String

For i = 0 To UBound(Split(txt, " "))
    word = Split(txt, " ")(i)
    word = UCase(Left(word, 1)) & LCase(Mid(word, 2))
    If isAcronym(word) Then word = UCase(word)
    If i > 0 Then
        If isPronoun(word) Then word = LCase(word)
    End If
    result = result & " " & word
Next i

gramUpper = Mid(result, 2)

End Function