#Example 1_1
import math
#To add the given Displacements Graphically
d1=25 #units in cm
d2=10 #units in cm
d3=30 #units in cm
R=math.sqrt(d1**2+d2**2+d3**2) #units in cm
theta1=30 #units in degrees
theta2=90 #units in degrees
theta3=120 #units in degrees
theta=360-(theta1+theta2+theta3) #units in degrees
print "The Resultant R=",round(R,2)," cm\n"
print "Theta=",round(theta)," degrees"
#In text book the answer is printed wrong as R=49cm and theta=82 degrees but the correct answer is R=40.31cm and theta=120 degrees
#Example 1_2
import math
# To add the given vector displacements
a=1 #units in meters
b=3 #units in meters
c=5 #units in meters
d=6 #units in meters
theta1=90 #units in degrees
Rx_a=a*math.sin(theta1*math.pi/180) #units in meters
Rx_b=round(b*math.cos(theta1*math.pi/180)) #units in meters
theta2=37 #units in degrees
Rx_c=-round(c*math.cos(theta2*math.pi/180)) #units in meters
theta3=53 #units in degrees
Rx_d=-d*math.cos(theta3*math.pi/180)
Ry_a=round(a*math.cos(theta1*math.pi/180)) #units in meters
Ry_b=round(c*math.sin(theta2*math.pi/180)) #units in meters
Ry_c=round(c*math.sin(theta2*math.pi/180)) #units in meters
Ry_d=-(d*math.sin(theta3*math.pi/180)) #units in meters
Rx=Rx_a+Rx_b+Rx_c+Rx_d #units in meters
Ry=Ry_a+Ry_b+Ry_c+Ry_d #units in meters
R=sqrt(Rx**2+Ry**2) #units in meters
phi=round(math.atan(Ry/-(Rx))*180/math.pi) #units in degrees
phi=180-phi #units in degrees
print "The Resultant R=",round(R,2)," Meters\n"
print "The Angle theta=",round(phi)," degrees"
#Example 1_3
import math
#To subtract vector B from Vector A
Ax=8.7 #units in meters
Ay=5 #units in meters
Bx=-6 #units in meters
By=0 #units in meters
Rx=Ax-Bx #units in meters
Ry=Ay-By #units in meters
R=sqrt(Rx**2+Ry**2) #units in meters
theta=round(math.atan(Ry/(Rx))*180/math.pi) #units in degrees
print "Resultant R=",round(R,1)," Meters\n"
print "Angle Theta=",round(theta)," Degrees"
#Example 1_4
import math
#To calculate the Volume
r=3*10**-5 #units in meters
L=0.20 #units in meters
V=math.pi*r**2*L #Units in meter**3
print "Volume V=",round(V,12),"Meter**3"