Skip to content

Commit 4c81b56

Browse files
Add files via upload
Vectors Functions Using Numpy
1 parent 1c25e31 commit 4c81b56

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Vectors_functions.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import numpy as np
2+
import math
3+
a=np.array([1,2,3])
4+
b=np.array([4,5,6])
5+
dot_ab=np.dot(a,b)
6+
print("Dot Product is = ",dot_ab)
7+
cross_ab=np.cross(a,b)
8+
print("Cross Product is = ",cross_ab)
9+
mag_a = np.linalg.norm(a)
10+
mag_b = mag_a = np.linalg.norm(b)
11+
12+
print("Magnitude of A: ",mag_a)
13+
print("Magnitude of B: ",mag_b)
14+
cos_theta = dot_ab / (mag_a * mag_b)
15+
ang_ab=np.arccos(cos_theta)
16+
angle_degree = np.degrees(ang_ab)
17+
print("Angle b/w AB (in radians) : ",ang_ab)
18+
print("Angle b/w AB (in degree) : " ,angle_degree)

0 commit comments

Comments
 (0)