scale_vector

compas.geometry.scale_vector(vector, factor)[source]

Scale a vector by a given factor.

Parameters
  • vector ([float, float, float] | Vector) – XYZ components of the vector.

  • factor (float) – The scaling factor.

Returns

[float, float, float] – The scaled vector.

Examples

>>> scale_vector([1.0, 2.0, 3.0], 2.0)
[2.0, 4.0, 6.0]
>>> v = [2.0, 0.0, 0.0]
>>> scale_vector(v, 1 / length_vector(v))
[1.0, 0.0, 0.0]