mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
Add files via upload
This commit is contained in:
16
mathgenerator/funcs/AngleBtwVectors.py
Normal file
16
mathgenerator/funcs/AngleBtwVectors.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import eucldianNorm
|
||||||
|
import math
|
||||||
|
from .__init__ import *
|
||||||
|
|
||||||
|
|
||||||
|
def AngleBtwVectors(v1: list, v2: list):
|
||||||
|
sum = 0
|
||||||
|
for i in v1:
|
||||||
|
for j in v2:
|
||||||
|
sum += i * j
|
||||||
|
|
||||||
|
mags = euclidianNorm(v1) * euclidianNorm(v2)
|
||||||
|
problem = f"angle between the vectors {v1} and {v2} is:"
|
||||||
|
solution = math.acos(sum / mags)
|
||||||
|
# would return the answer in radians
|
||||||
|
return problem, solution
|
||||||
7
mathgenerator/funcs/eucldianNorm.py
Normal file
7
mathgenerator/funcs/eucldianNorm.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from .__init__ import *
|
||||||
|
|
||||||
|
|
||||||
|
def euclidianNorm(v1: list):
|
||||||
|
problem = f"Euclidian norm or L2 norm of the vector{v1} is:"
|
||||||
|
solution = sqrt(sum([i**2 for i in v1]))
|
||||||
|
return problem, solution
|
||||||
Reference in New Issue
Block a user