Skip to content

Commit 870aae8

Browse files
committed
pybricks.tools: Document cross product.
1 parent 9cde749 commit 870aae8

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

doc/main/tools/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@
3131
.. pybricks-requirements:: stm32-float
3232

3333
.. autofunction:: pybricks.tools.vector
34+
35+
.. autofunction:: pybricks.tools.cross

jedi/tests/test_complete_import.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def test_from_pybricks_tools_import():
155155
code = "from pybricks.tools import "
156156
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
157157
assert [c["insertText"] for c in completions] == [
158+
"cross",
158159
"DataLog",
159160
"Matrix",
160161
"StopWatch",

src/pybricks/tools.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,21 @@ def vector(*args):
207207
"""
208208

209209

210+
def cross(a: Matrix, b: Matrix) -> Matrix:
211+
"""
212+
cross(a, b) -> Matrix
213+
214+
Gets the cross product ``a`` × ``b`` of two vectors.
215+
216+
Arguments:
217+
a (Matrix): A three-dimensional vector.
218+
b (Matrix): A three-dimensional vector.
219+
220+
Returns:
221+
The cross product, also a three-dimensional vector.
222+
"""
223+
224+
210225
# HACK: hide from jedi
211226
if TYPE_CHECKING:
212227
del Number

0 commit comments

Comments
 (0)