sum_vectors
- compas.geometry.sum_vectors(vectors, axis=0)[source]
Calculate the sum of a series of vectors along the specified axis.
- Parameters
vectors (list) – A list of vectors.
axis (int, optional) – If
axis == 0
, the sum is taken per column. Ifaxis == 1
, the sum is taken per row.
- Returns
list – The length of the list is
len(vectors[0])
, ifaxis == 0
. The length islen(vectors)
, otherwise.
Examples
>>> vectors = [[1.0, 2.0, 3.0], [1.0, 2.0, 3.0], [1.0, 2.0, 3.0]] >>> sum_vectors(vectors) [3.0, 6.0, 9.0] >>> sum_vectors(vectors, axis=1) [6.0, 6.0, 6.0]