p1_mrg_vector2

2899 days ago by LAC2011

a=vector([1,0,5]);a #initialize a vector in R^3 
       
b=vector([-2,1,0]);b #initialize a vector in R^3 
       
c=a.cross_product(b);c #vector product 
       
d=b.cross_product(a);d #vector product 
       
l=a.plot(rgbcolor='red') m=b.plot(rgbcolor='blue') n=c.plot(rgbcolor='green') o=d.plot(rgbcolor='orange') l+m+n+o 
       
#magnitude of axb is the area of the parallelogram defined a and b area=c.norm();show(area) area.n(digits=20) 
       

#angle between a and b a la torque in radians theta=asin(area/norm(a)/norm(b));show(theta) theta.n(digits=20) 
       

#angle between a and b a la torque in degrees theta2=theta*180/pi;show(theta2) theta2.n(20) 
       

e=vector([1,1,1]);e #initialize a vector R^3 
       
#volume of a parallelopiped vol=e.dot_product(c);abs(vol) 
       
#dilation f=2*a;f 
       
#dilation g=-3*b;g 
       
g.plot(rgbcolor='red')+b.plot(rgbcolor='blue') 
       
l=a.plot(rgbcolor='red') k=b.plot(rgbcolor='blue') m=e.plot(rgbcolor='green') l+k+m