vector_component

compas.geometry.vector_component(u, v)[source]

Compute the component of u in the direction of v.

Parameters
Returns

[float, float, float] – The component of u in the direction of v.

Notes

This is similar to computing direction cosines, or to the projection of a vector onto another vector. See the respective Wikipedia pages (1, 2) for more info.

References

1

Direction cosine. Available at https://en.wikipedia.org/wiki/Direction_cosine.

2

Vector projection. Available at https://en.wikipedia.org/wiki/Vector_projection.

Examples

>>> vector_component([1.0, 2.0, 3.0], [1.0, 0.0, 0.0])
[1.0, 0.0, 0.0]