eek
08-24-2005, 10:45 AM
Ok,
So Mark Tsang and I last night were trying to figure this out. I might just be to do with max 4 but i'll post it anyway. So i have 2 points: 'a' and 'b' and a third 'c'
So im trying to calculate the rotation of 'c's [2] off the position of 'a' and 'b'. I have 'a' and 100 in z and 'b' 100 in x. So if you draw a line between the two the angle you get is 45 degrees. like the angles of a triangle.
so as a max script this works fine:
d1 = $a.pos[3]-$c.pos[3] -- this gets on length (opposite)
d2 = distance $a.pos $b.pos
then:
if $b.pos[1] > $a.pos[1] then n = asin(d1/d2) else n = -asin(d1/d2)
$c.rotation.controller[2].value = n -- you remove this and the 'n' in a script controller but for ms is to check it works.
so asin is finding the trigometric angle, you need the if clause and -asin if 'a' goes behind 'b' in x
So this is fine for ms you evaluate it and it produces the right result but when i convert it to a float_script on 'c' [2] rotation it goes whacky and spins like crazy!! Anyone know whats going on? Is it a quat thing? Am i get aditional rotations in the script?
Im adding dependsOn $a $b to the script to see a result is this causing it?
eek
So Mark Tsang and I last night were trying to figure this out. I might just be to do with max 4 but i'll post it anyway. So i have 2 points: 'a' and 'b' and a third 'c'
So im trying to calculate the rotation of 'c's [2] off the position of 'a' and 'b'. I have 'a' and 100 in z and 'b' 100 in x. So if you draw a line between the two the angle you get is 45 degrees. like the angles of a triangle.
so as a max script this works fine:
d1 = $a.pos[3]-$c.pos[3] -- this gets on length (opposite)
d2 = distance $a.pos $b.pos
then:
if $b.pos[1] > $a.pos[1] then n = asin(d1/d2) else n = -asin(d1/d2)
$c.rotation.controller[2].value = n -- you remove this and the 'n' in a script controller but for ms is to check it works.
so asin is finding the trigometric angle, you need the if clause and -asin if 'a' goes behind 'b' in x
So this is fine for ms you evaluate it and it produces the right result but when i convert it to a float_script on 'c' [2] rotation it goes whacky and spins like crazy!! Anyone know whats going on? Is it a quat thing? Am i get aditional rotations in the script?
Im adding dependsOn $a $b to the script to see a result is this causing it?
eek
