01_getMagneticFieldVector

////////MAGNETIC FIELD DRAW///////////////////////////////////////////////////////
///PROC GET DIRMAGSUM VECTOR
global proc vector getSum (string $test11, string $charges[])
{
$k= 2;
float $dis;
vector $vadd,$vcharg;
global vector $dirMagSum;
global vector $test;

$charge0=$charges[0];
vector $dirMagSum = <<0,0,0>>;

for ($charge0 in $charges)
{
float $chargeLoad= `getAttr ($charge0+”.scaleX”)`;
//distance to charge
$test= `pointPosition $test11`;
$vcharg= `pointPosition $charge0`;
$vadd= $vcharg-$test;
$dis=mag($vadd);

//get force
$dpow= `pow $dis 2`;
$Force=$k*$chargeLoad/$dpow;

//create vector of direction and force
$dirMag= ($vcharg+(-$test))*$Force;
$dirMagSum= $dirMagSum+$dirMag;
}

return $dirMagSum;
return $test;
}
///END

////////////////////////////////////////////////////////////////////////////////

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s