c4dynamics.states.state.state.vel_mag

Contents

c4dynamics.states.state.state.vel_mag#

state.vel_mag()[source]#

Velocity Magnitude.

Calculates the magnitude of the object velocity :

\[vel mag = \sum_{k=v_x,v_y,v_z} self.k^2\]

If the state doesn’t include any velocity coordinate (vx, vy, vz), a ValueError is raised.

Returns:

out (float) – Euclidean norm of the velocity vector. The return type specifically is a numpy.float64.

Raises:

TypeError – If the state does not include any velocity coordinate (vx, vy, vz).

Note

In the context of vel_mag(), vx, vy, vz, (case sensitive) are considered velocity coordinates.

Examples

>>> s = c4d.state(vx = 7, vy = 24)
>>> s.vel_mag()
25.0
>>> s = c4d.state(x = 100, y = 0, vx = -10, vy = 7)
>>> s.vel_mag()   
12.2...

Uncommenting the following line throws a type error:

>>> s = c4d.state(x = 100, y = 0)
>>> # s.vel_mag()
TypeError: state must have at least one velocity coordinate (vx, vy, or vz)