Un companiero del trabajo me pregunto como habia hecho para encontrar el angulo entre los vectores (que es la parte mas importante del script cgx_wornEdges) para poder aplicar el mismo proceso en otros programas. La verdad es que en el script para Maya lo hice con una funcion especifica de MEL pero ese angulo se puede descubrir usando un poco de algebra lineal.
Hice otro script que hace toda esta matematica pero esta vez es Python puro y duro por lo cual lo pueden usar en cualquier soft que les acepte Python.
cgx_angleBetweenVectorsBasicamente tienen que llamar al script pasandole dos argumentos (los dos vectores) y el script les va a devolver el angulo en grados.
Puse cuatro lineas de codigo que pueden "descomentar" para testear como funciona.
Espero que les sirva.
Saludo!!
PD: En
Khan Academy pueden encontrar mas data sobre la matematica detras de esto.
ENGLISH:
A workmate asked me how I found the angle between the vectors (which is the most important process of the cgx_wornEdges script) so that he could apply the same technique in other software. The truth is that in the Maya script I used an specific MEL function but this angle can be found using some Linear Algebra.
So I did another script that does all this mathematic for you an this is just pure Python, which means you can use it in any other soft that works with Python.
cgx_angleBetweenVectorsBasically, you have to call the script passing two arguments (the two vectors) and the script will return the resulting angle in degrees.
I left four lines of code that you can uncomment if you want to test how this works.
Hope this will be useful.
Cheers!!
PD: In
Khan Academy you'll find more info about the math behind this.