Skip to content

Commit

Permalink
pybricks.tools: Document cross product.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Apr 21, 2023
1 parent 9cde749 commit 870aae8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/main/tools/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@
.. pybricks-requirements:: stm32-float

.. autofunction:: pybricks.tools.vector

.. autofunction:: pybricks.tools.cross
1 change: 1 addition & 0 deletions jedi/tests/test_complete_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def test_from_pybricks_tools_import():
code = "from pybricks.tools import "
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
assert [c["insertText"] for c in completions] == [
"cross",
"DataLog",
"Matrix",
"StopWatch",
Expand Down
15 changes: 15 additions & 0 deletions src/pybricks/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,21 @@ def vector(*args):
"""


def cross(a: Matrix, b: Matrix) -> Matrix:
"""
cross(a, b) -> Matrix
Gets the cross product ``a`` × ``b`` of two vectors.
Arguments:
a (Matrix): A three-dimensional vector.
b (Matrix): A three-dimensional vector.
Returns:
The cross product, also a three-dimensional vector.
"""


# HACK: hide from jedi
if TYPE_CHECKING:
del Number

0 comments on commit 870aae8

Please sign in to comment.