You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/algebra.rst
+36-9Lines changed: 36 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,18 +19,18 @@ General Remarks
19
19
-----------------
20
20
1. Operators can be either **binary** (i.e. involving two objects) or **unary**.
21
21
22
-
2. The resulting type of **binary** operations is either a **new object of the left operand's class** or a bool.
22
+
2. The resulting type of **binary** operations is either a **new object of the left operand's class,** a bool or (for dot products) a float.
23
23
24
24
3. The result of **unary** operations is either a **new object** of the same class, a bool or a float.
25
25
26
-
4. The binary operators *+, -, *, /* are defined for all classes. They *roughly* do what you would expect -- **except, that the second operand ...**
26
+
4. The binary operators `+, -, *, /` are defined for all classes. They *roughly* do what you would expect -- **except, that the second operand ...**
27
27
28
28
- may always be a number which then performs the operation on every component of the first one,
29
29
- may always be a numeric sequence of the same length (2, 4 or 6) -- we call such sequences :data:`point_like`, :data:`rect_like`, :data:`quad_like` or :data:`matrix_like`, respectively.
30
30
31
-
5. Rectangles support additional binary operations: **intersection** (operator *"&"*), **union** (operator *"|"*) and **containment** checking.
31
+
5. Rectangles support **additional binary** operations: **intersection** (operator `"&"`), **union** (operator `"|"`) and **containment** checking.
32
32
33
-
6. Binary operators fully support in-place operations, so expressions like `a /= b` are valid if b is numeric or "a_like".
33
+
6. Binary operators fully support in-place operations. So if "°" is a binary operator then the expression `a °= b` is always valid and the same as `a = a ° b`. Therefore, be careful and do **not** do `p1 *= p2` for two points, because thereafter "p1" is a **float**.
34
34
35
35
36
36
Unary Operations
@@ -50,17 +50,21 @@ Oper. Result
50
50
51
51
Binary Operations
52
52
------------------
53
-
For every geometry object "a" and every number "b", the operations "a ° b" and "a °= b" are always defined for the operators *+, -, *, /*. The respective operation is simply executed for each component of "a". If the **second operand is not a number**, then the following is defined:
53
+
These are expressions like `a ° b` where "°" is any of the operators `+, -, *, /`. Also binary operations are expressions of the form `a == b` and `b in a`.
If "b" is a number, then the respective operation is executed for each component of "a". Otherwise, if "b" is **not a number,** then the following happens:
0 commit comments