klampt.math.vectorops module

Allows treating tuples/lists as vectors


Adds one or more vectors.

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

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

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

Subtract a vector b from a, or subtract a scalar

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

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

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

Elementwise division with another vector, or with a scalar.

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

Elementwise max

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

Elementwise min

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

Dot product.


Returns the norm of a, squared.


L2 norm

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.


L2 norm


L1 norm


L-infinity norm

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

Squared L2 distance

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

L2 distance

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

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

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

Linear interpolation between a and b