pythagoras.vector module¶
- class pythagoras.vector.Vector(x: float, y: float)[source]¶
Bases:
objectTwo-dimensional vector with common operations.
- Variables:
x (float) – \(x\) component of the vector.
y (float) – \(y\) component of the vector.
- classmethod from_two_points(p1: tuple[float, float], p2: tuple[float, float]) Self[source]¶
Constructor for the vector that joins two points.
- Parameters:
p1 – Initial point.
p2 – End point.
- Returns:
The vector that goes from
p1top2.
- property perp: Self¶
Orthogonal complement (the vector after the map \((x, y) \mapsto (-y, x)\)).
- classmethod polar(r: float, theta: float) Self[source]¶
Constructs a vector expressed in polar coordinates.
- Parameters:
r – Magnitude of the vector.
theta – Angle with respect to the positive \(x\)-axis.
- Returns:
The corresponding vector.
- property unitary: Self¶
Vector normalized to have unit norm.
- x: float¶
- y: float¶