% MotionGenesis file: MGVectorExample.txt %--------------------------------------------------- % Create sets of right-handed orthogonal unit vectors. RigidFrame A % Creates Ax>, Ay>, Az> RigidBody B % Creates Bx>, By>, Bz> %--------------------------------------------------- % Define other vectors in terms of these unit vectors. v> = 2*Ax> + 3*Ay> + 4*Az> w> = Vector( A, 6, 7, 8 ) F> = Vector( B, [3, 5, 7] ) % Multiply the vector v> by 5. vFive> = 5 * v> % Add vectors v> and w>. addVW> = v> + w> % Dot-multiply v> with w>. dotVW = Dot( v>, w> ) % Cross-multiply v> with w> and form w> x (w> x v>). crossVW> = Cross( w>, v> ) crossWWV> = Cross( w>, Cross(w>,v>) ) % Find the magnitude and magnitude-squared of v>. magV = GetMagnitude( v> ) magVSquared = GetMagnitudeSquared( v> ) % Form the unit vector in the direction of v>. unitV> = GetUnitVector( v> ) % Find the radian-measure of the angle between v> and w>. angleBetweenVW = GetAngleBetweenVectors( v>, w> ) % Form the ordinary time-derivative of the vector t*v> + sin(t)*w> in reference frame A. vectorDerivative> = Dt( t*v> + sin(t)*w>, A ) % Form a rotation matrix relating Bx>, By>, Bz> to Ax>, Ay>, Az> in terms of time t. B.SetRotationMatrixZ( A, t ) % Express vector v> in terms of Bx>, By>, Bz>. Express( v>, B ) % To express vector v> + F> in terms of Ax>, Ay>, Az>, type sumInTermsOfAxyz> = Express( v> + F>, A ) % Form the Bx>, By>, Bz> measures of w>. wMatrix = Vector( B, w> ) % Save input and output responses. Save MGVectorExample.html Quit