27 lines
462 B
Text
27 lines
462 B
Text
|
|
T Vector
|
|||
|
|
Float x, y
|
|||
|
|
|
|||
|
|
F (x, y)
|
|||
|
|
.x = x
|
|||
|
|
.y = y
|
|||
|
|
|
|||
|
|
F +(vector)
|
|||
|
|
R Vector(.x + vector.x, .y + vector.y)
|
|||
|
|
|
|||
|
|
F -(vector)
|
|||
|
|
R Vector(.x - vector.x, .y - vector.y)
|
|||
|
|
|
|||
|
|
F *(mult)
|
|||
|
|
R Vector(.x * mult, .y * mult)
|
|||
|
|
|
|||
|
|
F /(denom)
|
|||
|
|
R Vector(.x / denom, .y / denom)
|
|||
|
|
|
|||
|
|
F String()
|
|||
|
|
R ‘(#., #.)’.format(.x, .y)
|
|||
|
|
|
|||
|
|
print(Vector(5, 7) + Vector(2, 3))
|
|||
|
|
print(Vector(5, 7) - Vector(2, 3))
|
|||
|
|
print(Vector(5, 7) * 11)
|
|||
|
|
print(Vector(5, 7) / 2)
|