api/aspherix_vector.h

This is the header file used to define a 3-D vector class. The member functions are:


Vector

Constructor

operator[]

Get a component value of the vector.

operator_getitem

Helper function.

operator+

Add two vectors.

operator+=

Add a vector value to an existing one.

operator-

Subtract two vectors.

operator-=

Subtract a vector value from an existing one.

operator*

Dot product if the argument on the left is also a vector or scalar multiplication if the argument on the left is a scalar value.

operator*=

Scalar multiplication with a scalar value.

Hadamard

Hadamard product (element-wise product) of two vectors.

operator/

Scalar division.

operator/=

Scalar division of an existing vector.

operator-

Flip a vector.

operator=

Copy a vector.

cross

Cross product of a vector with another one.

v1.cross(v2)

is equivalent to \vec{v}_1 \times \vec{v}_2.

length_squared

Squared norm of a vector.

length

Norm of a vector.

abs

Returns a vector with the absolute values of the components of the original vector

sgn

Returns a vector with the results of the signum (sign) function applied to the components of the original vector

normalize

Convert a vector to a unit vector.

min

Can either be called with a scalar or a vector. The return value is a vector with the minimum of the component of the original vector with the scalar or the corresponding component of the vector argument, respectively.

max

Can either be called with a scalar or a vector. The return value is a vector with the maximum of the component of the original vector with the scalar or the corresponding component of the vector argument, respectively.

projectOn

Project the original vector (v) onto a second vector (on), i.e the return value is on (v.on)/\|on\|^2.

print

Function to print a vector to stdout.

as_string

Returns the vector as string, e.g. for printing.