vector.py ersetzen

This commit is contained in:
2025-01-05 17:56:54 +00:00
parent 167c6753ff
commit d50a8e7301

View File

@@ -38,7 +38,7 @@ class Vector(object):
new_coordinates = [x-y for x,y in zip(self.coordinates, v.coordinates)]
return Vector(new_coordinates)
def times_scalar(self, c):
def skalar_multiplikation(self, c):
new_coordinates = [c*x for x in self.coordinates]
return Vector(new_coordinates)
@@ -51,7 +51,7 @@ class Vector(object):
coordinates_squared = [x**2 for x in self.coordinates]
#pdb.set_trace()
return sqrt(sum(coordinates_squared))
def normalized(self):
try:
@@ -63,16 +63,14 @@ class Vector(object):
# Tests
veka1 = Vector([0,5,3])
veka2 = Vector([2,2,1])
a = Vector([3,4])
b = Vector([10,5])
c = a.minus(b.skalar_multiplikation((1/2)))
print (veka1.plus(veka2))
veka3 = Vector([3,4])
print(veka3.laenge())
veka4 = Vector([10,5])
print(veka4.laenge()) #magnitude
print(c)
print(a.laenge())
print(b.laenge())
print(c.laenge())