c4dynamics.states.state.state.addvars#
- state.addvars(**kwargs)[source]#
Add state variables.
Adding variables to the state outside the
state
constructor is possible by usingaddvars()
.- Parameters:
**kwargs (float or int) – Keyword arguments representing the variables and their initial conditions. Each key is a variable name and each value is its initial condition.
Note
If
store()
is called before adding the new variables, then the time histories of the new states are filled with zeros to maintain the same size as the other state variables.Examples
>>> s = c4d.state(x = 0, y = 0) >>> print(s) [ x y ] >>> s.addvars(vx = 0, vy = 0) >>> print(s) [ x y vx vy ]
calling
store()
before adding the new variables:>>> s = c4d.state(x = 1, y = 1) >>> s.store() >>> s.store() >>> s.store() >>> s.addvars(vx = 0, vy = 0) >>> s.data('x')[1] [1 1 1] >>> s.data('vx')[1] [0 0 0]