vector module

This module contains the Vector3D class to be used for illustrating how to document and test a project.

A good example of the NumPy style can be found here: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html

class vector.Vector3D(x, y, z)[source]

Bases: object

A class for creating 3D vectors.

Parameters:
  • x (float) – x - coordinate
  • y (float) – y - coordinate
  • z (float) – z - coordinate

Example

>>> u = Vector3D(1, 1, 1)
>>> v = Vector3D(1, 2, 3)
>>> w = u + v
>>> print(w)
(2, 3, 4)
cross(other)[source]

Compute the cross product.

\[w = u \times v\]

with

\[\begin{split}w_1 &= u_2 v_3 - u_3 v_2 \\ w_2 &= u_1 v_3 - u_3 v_1 \\ w_3 &= u_1 v_2 - u_2 v_1\end{split}\]
Parameters:other (Vector3D) – Vector that you want to dot
Returns:The dot product
Return type:float
dot(other)[source]

Compute the dot product.

\[u \cdot v = u_1v_1 + u_2v_2 + u_3v_3\]
Parameters:other (Vector3D) – Vector that you want to dot.
Returns:The dot product
Return type:float
length

Get length of vector (2-norm)

perpendicular(other)[source]

Check if a vector is perpendicular

Parameters:other (Vector3D) – The vector that you want to check is perpendicular.
Returns:True if they are perpendicular, and False otherwise.
Return type:bool
unit()[source]

Return a vector in pointing in the same direction of unit length.