klampt.math.vectorops module

Allows treating tuples/lists as vectors


Adds one or more vectors.

klampt.math.vectorops.cross(a, b)[source]

Cross product between a 3-vector or a 2-vector

klampt.math.vectorops.distance(a, b)[source]
klampt.math.vectorops.distanceSquared(a, b)[source]
klampt.math.vectorops.div(a, b)[source]

Elementwise division with another vector, or with a scalar.

klampt.math.vectorops.dot(a, b)[source]

Dot product.

klampt.math.vectorops.interpolate(a, b, u)[source]

Linear interpolation between a and b

klampt.math.vectorops.madd(a, b, c)[source]

Return a+c*b where a and b are vectors.

klampt.math.vectorops.maximum(a, b)[source]

Elementwise max

klampt.math.vectorops.minimum(a, b)[source]

Elementwise min

klampt.math.vectorops.mul(a, b)[source]

Multiply a vector either elementwise with another vector, or with a scalar.


L2 norm


Returns the norm of a, squared.


L1 norm


L2 norm


L-infinity norm

klampt.math.vectorops.sub(a, b)[source]

Subtract a vector b from a, or subtract a scalar

klampt.math.vectorops.unit(a, epsilon=1e-05)[source]

Returns the unit vector in the direction a. If the norm of a is less than epsilon, a is left unchanged.