import VectorUtil import math from VectorLength import vector_length from ScalarProduct import scalar_product def angle_in_between(u, v): product = scalar_product(u, v) print() ulen = vector_length(u) print() vlen = vector_length(v) print() print("cos(γ) = u*v / |u|*|v|") print(product, " / (", ulen, " * ", vlen, ")") print(product, " / (", ulen * vlen, ")") cos = product/(ulen * vlen) print("cos(γ) = ", cos) print("γ = arccos(cos(γ))") print("γ = ", math.acos(cos), "rad ~", math.degrees(math.acos(cos)), "°") if(__name__ == "__main__"): u = VectorUtil.read_vector("Input U:") v = VectorUtil.read_vector("Input V:") angle_in_between(u, v)
from OrtogonalVector import ortogonal_vector from ScalarProduct import scalar_product import VectorUtil def triple_product(a, b, c): print("[a, b, c] = (a×b)·c ") ort = ortogonal_vector(a, b) vec = scalar_product(ort, c) print("[a, b, c] =", vec) return vec if (__name__ == "__main__"): a = VectorUtil.read_vector("Input A:") b = VectorUtil.read_vector("Input B:") c = VectorUtil.read_vector("Input C:") triple_product(a, b, c)