PDA

View Full Version : vector math for a bendy arm


chi
03-23-2009, 10:39 PM
ok so...i'm definately not a whiz with the xpresso/math/anything that requires a bit of logical thought...but I feel i should be able to follow a tutorial...right now what i'm trying to recreate is this.

vector $A = unit (<<(L_WristLoc.translateX - L_ShoulderLoc.translateX),
(L_WristLoc.translateY - L_ShoulderLoc.translateY),
(L_WristLoc.translateZ - L_ShoulderLoc.translateZ)>>);
vector $B = <<(L_Shoulder_ProjectLoc.translateX - L_ElbowLoc.translateX),
(L_Shoulder_ProjectLoc.translateY - L_ElbowLoc.translateY),
(L_Shoulder_ProjectLoc.translateZ - L_ElbowLoc.translateZ)>>;
vector $C = <<(L_Elbow_ProjectLoc.translateX - L_ElbowLoc.translateX),
(L_Elbow_ProjectLoc.translateY - L_ElbowLoc.translateY),
(L_Elbow_ProjectLoc.translateZ - L_ElbowLoc.translateZ)>>;
float $dotProd = dot($A, $B);
float $length = mag($A);
float $scale = $dotProd / ($length * $length);
L_Shoulder_ResultLoc.translateX = L_ElbowLoc.translateX + ($A.x * $scale);
L_Shoulder_ResultLoc.translateY = L_ElbowLoc.translateY + ($A.y * $scale);
L_Shoulder_ResultLoc.translateZ = L_ElbowLoc.translateZ + ($A.z * $scale);
float $dotProd = dot($A, $C);
float $length = mag($A);
float $scale = $dotProd / ($length * $length);
L_Elbow_ResultLoc.translateX = L_ElbowLoc.translateX + ($A.x * $scale);
L_Elbow_ResultLoc.translateY = L_ElbowLoc.translateY + ($A.y * $scale);
L_Elbow_ResultLoc.translateZ = L_ElbowLoc.translateZ + ($A.z * $scale);

so far i seem to have things going good...but i have reached to issues...the dotprod is coming out as a real number and not a vector...so like 654,654,654 and i can not find any way of calculating the mag (vectors magnitude) value. can anyone with a mathy brain help me?

Sneaker
03-24-2009, 01:59 PM
> float $dotProd = dot($A, $B);

what do you expect?

-Michael

chi
03-24-2009, 06:22 PM
in regards to the dot product thing i guess that was my misunderstanding...after sometime on wikipedia I found that it is supposed to output a real instead of a vector...this is me not knowing math...but anyway I scrapped this tutorial...mostly cause kai helped me figure out how to do it all with constraints and ditch all the mel script crap that maya has to deal with.

underearth
12-04-2009, 02:13 PM
can u explain what and how u did that with constarints

LucentDreams
12-04-2009, 02:37 PM
Look under advanced, Bret does a basic version of our setup.

http://www.cineversity.com/tutorials/index.asp?cid=5

CGTalk Moderation
12-04-2009, 02:37 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.