States library#

This page is an introduction to the states library. For the different pre-defined states themselves, go to Pre-defined state objects.

Each one of the states in the library is inherited from the state class and has the benefit of its attributes, like store() data() etc.

1. Data Point#

C4dynamics provides built-in entities for developing and analyzing algorithms of objects in space and time:

datapoint: a class defining a point in space: position, velocity, and mass.

rigidbody: a class rigidbody a class defining a rigid body in space, i.e. an object with length and angular position.

../_images/body_states.svg

Figure: Conceptual diagram showing the relationship between the two fundamental objects used to describe bodies in space: 1) the datapoint, 2) the rigidbody. A rigidbody object extends the datapoint by adding on it body rotational motion.#

The datapoint is the most basic element in translational dynamics; it’s a point in space.

A datapoint serves as the building block for modeling and simulating the motion of objects in a three-dimensional space. In the context of translational dynamics, a datapoint represents a point mass in space with defined Cartesian coordinates \((x, y, z)\) and associated velocities \((v_x, v_y, v_z)\).

Data Attributes#

State variables:

\[X = [x, y, z, v_x, v_y, v_z]^T\]
  • Position coordinates, velocity coordinates.

Parameters:

  • mass: point mass.

Construction#

A datapoint instance is created by making a direct call to the datapoint constructor:

>>> from c4dynamics import datapoint
>>> dp = datapoint()
>>> print(dp)
[ x  y  z  vx  vy  vz ]

Initialization of an instance does not require any mandatory parameters. However, setting values to any of the state variables uses as initial conditions:

>>> dp = datapoint(x = 1000, vx = -100)

Functionality#

The inteqm() method uses the Runge-Kutta integration technique to evolve the state in response to external forces. The mechanics underlying the equations of motion can be found here.

The method plot() adds on the standard state.plot() the option to draw trajectories from side view and from top view.

See also

datapoint, eqm

2. Rigid Body#

The rigidbody class extends the functionality of the datapoint.

It introduces additional attributes related to rotational dynamics, such as angular position, angular velocity, and moment of inertia. The class leverages the capabilities of the datapoint class for handling translational dynamics and extends it to include rotational aspects. See the figure above.

Data Attributes#

State variables:

\[X = [x, y, z, v_x, v_y, v_z, {\varphi}, {\theta}, {\psi}, p, q, r]^T\]
  • Position, velocity, angles, angle rates.

Parameters:

  • mass: point mass.

  • I: vector of moments of inertia about 3 axes.

Construction#

A rigidbody instance is created by making a direct call to the rigidbody constructor:

>>> from c4dynamics import rigidbody
>>> rb = rigidbody()
>>> print(rb)
[ x  y  z  vx  vy  vz  φ  θ  ψ  p  q  r ]

Similar to the datapoint, initialization of an instance does not require any mandatory parameters. Setting values to any of the state variables uses as initial conditions:

>>> from c4dynamics import d2r
>>> rb = rigidbody(theta = 10 * d2r, q = -1 * d2r)

Functionality#

The inteqm() method uses the Runge-Kutta integration technique to evolve the state in response to external forces and moments. The mechanics underlying the equations of motion can be found here and here.

BR and RB return Direction Cosine Matrices, Body from Reference ([BR]) and Reference from Body ([RB]), with respect to the instantaneous Euler angles (\(\varphi, \theta, \psi\)).

When a 3D model is provided, the method animate() animates the object with respect to the histories of the rigidbody attitude.

See also

rigidbody, eqm, rotmat

3. Pixel Point#

The pixelpoint class representing a data point in a video frame with a bounding box.

This class is particularly useful for applications in computer vision, such as object detection and tracking.

Data Attributes#

State variables:

\[X = [x, y, w, h]^T\]
  • Center pixel, box size.

Parameters:

  • fsize: frame size.

  • class_id: object classification.

Construction#

Usually, the pixelpoint instance is created immediately after an object detection:

>>> from c4dynamics import pixelpoint
>>> pp = pixelpoint(x = 50, y = 50, w = 15, h = 25) # (50, 50) detected object center, (15, 25) object bounding box
>>> pp.fsize = (100, 100)   # frame width and frame height
>>> pp.class_id = 'fox'
>>> print(pp)
[ x  y  w  h ]

Functionality#

box returns the bounding box in terms of top-left and bottom-right coordinates.

See also

pixelpoint, yolov3

Pre-defined state objects#

datapoint

A point in space.

rigidbody

Rigid body object.

pixelpoint

A pixel point in an image.