DYNAMICS C API
C-compatible interface to the DYNAMICS library
Loading...
Searching...
No Matches
dynamics.h File Reference

Public C interface to the DYNAMICS library. More...

#include <complex.h>
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  c_iteration_behavior
 Iteration statistics returned by nonlinear solver routines. More...
 
struct  c_frequency_sweep_controls
 Controls for a frequency sweep. More...
 
struct  c_iteration_controls
 Controls for nonlinear iteration routines. More...
 
struct  c_regression_statistics
 Regression statistics returned by fitting routines. More...
 
struct  c_dynamic_system_measurement
 A single dynamic-system input/output measurement record. More...
 
struct  c_lm_solver_options
 Options for the Levenberg-Marquardt solver. More...
 
struct  c_quaternion
 A quaternion stored as scalar component followed by vector terms. More...
 
struct  c_plane
 Plane coefficients satisfying a*x + b*y + c*z + d = 0. More...
 
struct  c_line
 A line represented by a point and direction vector. More...
 
struct  c_plucker_line
 A Pluecker line represented by direction and moment vectors. More...
 
struct  c_coordinate_system
 An orthonormal coordinate system. More...
 
struct  c_dh_parameter_set
 One Denavit-Hartenberg parameter set. More...
 
struct  c_dh_table
 A dynamically allocated Denavit-Hartenberg table. More...
 
struct  c_binary_link
 One link in a serial Denavit-Hartenberg linkage. More...
 
struct  c_serial_linkage
 A serial linkage and its link array. More...
 
struct  c_mechanism_link
 A multi-frame link used by a closed-loop mechanism. More...
 
struct  c_joint
 A joint connecting two mechanism link frames. More...
 
struct  c_rigid_body
 Rigid-body mass properties for direct variational integration. More...
 
struct  c_variational_state
 A non-owning view of one maximal-coordinate callback state. More...
 
struct  c_variational_integrator_settings
 Numerical controls for the maximal-coordinate variational integrator. More...
 
struct  c_joint_reaction
 World-frame joint reaction exerted on the joint's child link. More...
 
struct  c_linear_spring
 Linear spring between body-fixed points; body zero denotes ground. More...
 
struct  c_linear_damper
 Axial linear viscous damper between body-fixed points. More...
 
struct  c_torsional_spring
 Linear torsional spring bound to a revolute-joint axis. More...
 
struct  c_torsional_damper
 Twist-rate damper bound to a revolute-joint axis. More...
 
struct  c_axial_element_result
 Instantaneous scalar result for an axial force element. More...
 
struct  c_torsional_element_result
 Instantaneous scalar result for a torsional force element. More...
 
struct  c_polynomial
 A polynomial with dynamically allocated coefficients. More...
 
struct  c_transfer_function
 A numerator/denominator transfer-function pair. More...
 
struct  c_state_space_model
 A continuous state-space model with column-major matrices. More...
 
struct  c_material
 A linear-elastic-isotropic material. More...
 
struct  c_node
 A structural node with position and degrees of freedom. More...
 
struct  c_beam_element_2d
 A two-dimensional Bernoulli-Euler beam element. More...
 
struct  c_beam_element_3d
 A three-dimensional Bernoulli-Euler beam element. More...
 
struct  c_truss_element_2d
 A two-dimensional, pin-jointed, axial-only truss element with x and y translations at each node. More...
 
struct  c_truss_element_3d
 A three-dimensional, pin-jointed, axial-only truss element with x, y, and z translations at each node. More...
 
struct  c_spring_element_2d
 A two-dimensional linear, axial spring element with x and y translations at each node. More...
 
struct  c_spring_element_3d
 A three-dimensional linear, axial spring element with x, y, and z translations at each node. More...
 
struct  c_damper_element_2d
 A two-dimensional linear, axial viscous damper element with x and y translations at each node. More...
 
struct  c_damper_element_3d
 A three-dimensional linear, axial viscous damper element with x, y, and z translations at each node. More...
 
struct  c_mass_element_2d
 A two-dimensional translational point mass element. More...
 
struct  c_mass_element_3d
 A three-dimensional translational point mass element. More...
 

Macros

#define DYN_HYPERBOLIC_FIXED_POINT_SINK   100
 Hyperbolic fixed point classified as a sink.
 
#define DYN_HYPERBOLIC_FIXED_POINT_SOURCE   101
 Hyperbolic fixed point classified as a source.
 
#define DYN_HYPERBOLIC_FIXED_POINT_SADDLE   102
 Hyperbolic fixed point classified as a saddle.
 
#define DYN_NONHYPERBOLIC_FIXED_POINT_UNSTABLE   103
 Nonhyperbolic fixed point classified as unstable.
 
#define DYN_NONHYPERBOLIC_FIXED_POINT_NEUTRALLY_STABLE   104
 Nonhyperbolic fixed point classified as neutrally stable.
 
#define DYN_NONHYPERBOLIC_FIXED_POINT_CENTER   105
 Nonhyperbolic fixed point classified as a center.
 
#define DYN_REVOLUTE_JOINT   0
 Revolute joint type.
 
#define DYN_PRISMATIC_JOINT   1
 Prismatic joint type.
 
#define DYN_FIXED_JOINT   2
 Fixed joint type.
 
#define DYN_CYLINDRICAL_JOINT   3
 Cylindrical joint type.
 
#define DYN_UNIVERSAL_JOINT   4
 Universal joint type.
 
#define DYN_SPHERICAL_JOINT   5
 Spherical joint type.
 
#define DYN_FRF_ACCELERANCE_MODEL   1
 Frequency-response model expressed as accelerance.
 
#define DYN_FRF_RECEPTANCE_MODEL   2
 Frequency-response model expressed as receptance.
 
#define DYN_RUNGE_KUTTA_23   10
 Runge-Kutta 2/3 integration method.
 
#define DYN_RUNGE_KUTTA_45   11
 Runge-Kutta 4/5 integration method.
 
#define DYN_RUNGE_KUTTA_853   12
 Runge-Kutta 8/5/3 integration method.
 
#define DYN_ROSENBROCK   13
 Rosenbrock integration method.
 
#define DYN_BDF   14
 Backward-differentiation-formula integration method.
 
#define DYN_ADAMS   15
 Adams integration method.
 
#define DYN_KENNEDY_CARPENTER_4   16
 Kennedy-Carpenter fourth-order integration method.
 
#define DYN_KENNEDY_CARPENTER_5   17
 Kennedy-Carpenter fifth-order integration method.
 
#define DYN_TSITOURAS_5   18
 Tsitouras fifth-order integration method.
 
#define DYN_ACCELERANCE_MODEL   1
 Accelerance model selector for system identification.
 
#define DYN_RECEPTANCE_MODEL   2
 Receptance model selector for system identification.
 
#define DYN_H1   1
 H1 estimator selector for SISO frequency analysis.
 
#define DYN_H2   2
 H2 estimator selector for SISO frequency analysis.
 
#define DYN_LEVENBERG_MARQUARDT_UPDATE   1
 Levenberg-Marquardt damping update method.
 
#define DYN_QUADRATIC_UPDATE   2
 Quadratic damping update method.
 
#define DYN_NIELSEN_UPDATE   3
 Nielsen damping update method.
 
#define DYN_POINCARE_TWO_SIDED   0
 Store intersections with both directions of the Poincare plane.
 
#define DYN_POINCARE_ONE_SIDED_FROM_FRONT   1
 Store intersections approaching the Poincare plane from the front.
 
#define DYN_POINCARE_ONE_SIDED_FROM_BACK   2
 Store intersections approaching the Poincare plane from the back.
 
#define DYN_ONE_POINT_INTEGRATION_RULE   1
 Single-point Gauss integration rule.
 
#define DYN_TWO_POINT_INTEGRATION_RULE   2
 Two-point Gauss integration rule.
 
#define DYN_THREE_POINT_INTEGRATION_RULE   3
 Three-point Gauss integration rule.
 
#define DYN_FOUR_POINT_INTEGRATION_RULE   4
 Four-point Gauss integration rule.
 
#define DYN_VI_DENSE_SOLVER   1
 Dense LU solver for variational-integrator Newton systems.
 
#define DYN_VI_GRAPH_FACTORIZED_SOLVER   2
 Graph-factorized solver for variational-integrator Newton systems.
 
#define DYN_VI_FORCE_LEFT_ENDPOINT   1
 Evaluate applied loads at the current state (explicit left endpoint).
 
#define DYN_VI_FORCE_IMPLICIT_ENDPOINT   2
 Evaluate applied loads at the trial next state inside Newton.
 
#define DYN_VI_FORCE_MIDPOINT   3
 Evaluate applied loads at an interpolated midpoint state inside Newton.
 
#define DYN_NO_ERROR   0
 No error has been recorded.
 
#define DYN_MEMORY_ERROR   10000
 A memory allocation failed.
 
#define DYN_NULL_POINTER_ERROR   10001
 A required pointer or handle was NULL or invalid.
 
#define DYN_INVALID_INPUT_ERROR   10004
 An input argument was invalid.
 
#define DYN_MATRIX_SIZE_ERROR   100100
 A matrix was incorrectly sized.
 
#define DYN_ARRAY_SIZE_ERROR   100105
 An array was incorrectly sized.
 

Typedefs

typedef void(* c_error_handler) (int code, const char *message, void *user_data)
 Error handler callback.
 
typedef void(* c_vecfcn) (int nvar, int neqn, const double *x, double *f, void *user_data)
 Nonlinear vector function callback.
 
typedef void(* c_modal_excite) (int n, double freq, double complex *f, void *user_data)
 Modal force callback used by frequency-response routines.
 
typedef void(* c_harmonic_ode) (int n, double freq, double t, const double *x, double *dxdt, void *user_data)
 Harmonic ordinary-differential-equation callback.
 
typedef double(* c_window_function) (int n, int bin, void *user_data)
 Window function callback used by SISO frequency analysis.
 
typedef void(* c_constraint_equations) (int n, int neqn, int nparam, const double *xg, const double *fg, const double *xc, const double *p, double *fc, void *user_data)
 Constraint callback used by least-squares system identification.
 
typedef void(* c_ode_fit) (int n, int nparam, const double *mdl, double t, const double *x, double F, double *dxdt, void *user_data)
 ODE model callback used by system identification.
 
typedef void(* c_ss_excitation) (int n, double t, double *u, void *user_data)
 State-space input callback used by c_lti_solve.
 
typedef void(* c_ode_equations) (int n, double t, const double *x, double *dxdt, void *user_data)
 Ordinary-differential-equation callback.
 
typedef void(* c_poincare_coordinates) (int n, double t, const double *x, double coordinates[3], void *user_data)
 Poincare section coordinate callback.
 
typedef struct c_variational_state c_variational_state
 
typedef void(* c_variational_force) (const c_variational_state *state, double *force, double *torque, void *user_data)
 External force and torque callback for variational integration.
 
typedef void(* c_variational_constraint) (const c_variational_state *state, int nconstraint, double *value, void *user_data)
 Holonomic constraint callback for variational integration.
 
typedef void(* c_variational_constraint_jacobian) (const c_variational_state *state, int nconstraint, double *jacobian, int ldj, void *user_data)
 Reduced constraint-Jacobian callback.
 
typedef double(* c_linkage_prescribed_motion) (double t, void *user_data)
 Prescribed planar-link angular motion callback.
 
typedef void * c_mechanism
 Opaque handle to a closed-loop mechanism.
 
typedef void * c_linkage_dynamic_model
 Opaque linkage dynamic-model handle.
 
typedef void * c_structural_integrator
 Opaque linear structural time-integrator handle.
 

Functions

void c_set_error_handler (c_error_handler fcn, void *user_data)
 Register a handler invoked whenever the C interface records an error on the calling thread.
 
int c_get_last_error (void)
 Get the most recent error recorded on the calling thread.
 
int c_get_last_error_message (int n, char *buffer)
 Copy the message for the most recent error on the calling thread.
 
void c_clear_error (void)
 Clear the error recorded on the calling thread.
 
void c_matmul (int m, int n, int k, double alpha, const double *a, int lda, const double *b, int ldb, double beta, double *c, int ldc)
 Multiply two column-major matrices: c = alpha*a*b + beta*c.
 
double c_q_factor (double zeta)
 Compute the Q factor from a damping ratio.
 
double c_estimate_bandwidth (double fn, double zeta)
 Estimate the half-power bandwidth.
 
double c_logarithmic_decrement (double x1, double x2, int n)
 Compute logarithmic decrement from two peaks.
 
double c_damping_from_log_decrement (double delta)
 Convert logarithmic decrement to damping ratio.
 
void c_find_free_response_properties (int n, const double *t, const double *x, double s, int np, double *delta, double *fn, double *x1, double *x2, double *t1, double *t2)
 Extract damping and frequency properties from a free response.
 
double c_rise_time (double wn, double zeta)
 Compute the 10-to-90 percent rise time.
 
double c_find_settling_amplitude (int n, const double *x)
 Find the settled response amplitude.
 
double c_damping_from_fractional_overshoot (int n, const double *x)
 Estimate damping from fractional overshoot.
 
void c_evaluate_step_response (int n, double wn, double zeta, double xs, const double *t, double *x)
 Evaluate a second-order step response.
 
void c_rotate_x (double angle, double *r, int ldr)
 Build a rotation matrix about the x axis.
 
void c_rotate_y (double angle, double *r, int ldr)
 Build a rotation matrix about the y axis.
 
void c_rotate_z (double angle, double *r, int ldr)
 Build a rotation matrix about the z axis.
 
void c_rotate (const double i[3], const double j[3], const double k[3], double *r, int ldr)
 Build a rotation matrix from three basis vectors.
 
void c_acceleration_transform (const double alpha[3], const double omega[3], const double a[3], const double x[3], double *r, int ldr)
 Build an acceleration transformation matrix.
 
void c_velocity_transform (const double omega[3], const double v[3], const double x[3], double *r, int ldr)
 Build a velocity transformation matrix.
 
void c_determine_local_stability (int n, const double *a, int lda, double complex *ev, int *flag)
 Classify the eigenvalues of a linearized system for local stability.
 
void c_dh_forward_kinematics_table (const c_dh_table *tbl, double *T, int ldt)
 Compute forward kinematics from a Denavit-Hartenberg table.
 
void c_dh_forward_kinematics (int n, const double *alpha, const double *a, const double *theta, const double *d, double *T, int ldt)
 Compute serial Denavit-Hartenberg forward kinematics.
 
void c_dh_forward_kinematics_2 (const double *T1, int ldt1, const double *T2, int ldt2, double *T, int ldt)
 Multiply two homogeneous transforms.
 
void c_dh_forward_kinematics_3 (const double *T1, int ldt1, const double *T2, int ldt2, const double *T3, int ldt3, double *T, int ldt)
 Multiply three homogeneous transforms.
 
void c_dh_forward_kinematics_4 (const double *T1, int ldt1, const double *T2, int ldt2, const double *T3, int ldt3, const double *T4, double *T, int ldt)
 Multiply four homogeneous transforms.
 
void c_dh_forward_kinematics_5 (const double *T1, int ldt1, const double *T2, int ldt2, const double *T3, int ldt3, const double *T4, int ldt4, const double *T5, int ldt5, double *T, int ldt)
 Multiply five homogeneous transforms.
 
void c_dh_forward_kinematics_6 (const double *T1, int ldt1, const double *T2, int ldt2, const double *T3, int ldt3, const double *T4, int ldt4, const double *T5, int ldt5, const double *T6, int ldt6, double *T, int ldt)
 Multiply six homogeneous transforms.
 
void c_dh_forward_kinematics_7 (const double *T1, int ldt1, const double *T2, int ldt2, const double *T3, int ldt3, const double *T4, int ldt4, const double *T5, int ldt5, const double *T6, int ldt6, const double *T7, int ldt7, double *T, int ldt)
 Multiply seven homogeneous transforms.
 
void c_dh_forward_kinematics_8 (const double *T1, int ldt1, const double *T2, int ldt2, const double *T3, int ldt3, const double *T4, int ldt4, const double *T5, int ldt5, const double *T6, int ldt6, const double *T7, int ldt7, const double *T8, int ldt8, double *T, int ldt)
 Multiply eight homogeneous transforms.
 
void c_dh_jacobian (int n, const double *alpha, const double *a, const double *theta, const double *d, const int *jtypes, double *jac, int ldjac)
 Compute a Denavit-Hartenberg linkage Jacobian.
 
void c_dh_matrix (double alpha, double a, double theta, double d, double *T, int ldt)
 Build one Denavit-Hartenberg homogeneous transform.
 
void c_dh_rotate_x (double alpha, double *T, int ldt)
 Build the Denavit-Hartenberg x-axis rotation matrix.
 
void c_dh_rotate_z (double theta, double *T, int ldt)
 Build the Denavit-Hartenberg z-axis rotation matrix.
 
void c_dh_translate_x (double a, double *T, int ldt)
 Build the Denavit-Hartenberg x translation matrix.
 
void c_dh_translate_z (double d, double *T, int ldt)
 Build the Denavit-Hartenberg z translation matrix.
 
void c_jacobian_generating_vector (const double *d, const double *k, const double *R, int ldr, int jtype, double jvec[6])
 Generate one joint Jacobian column.
 
void c_solve_inverse_kinematics (int njoints, int neqn, const c_vecfcn mdl, const double *qo, const double *constraints, const double *qmax, const double *qmin, double *jvar, double *resid, c_iteration_behavior *ib, void *user_data)
 Solve a nonlinear inverse-kinematics problem.
 
void c_to_angle_axis (const double *r, int ldr, double *angle, double axis[3])
 Convert a rotation matrix to angle-axis form.
 
void c_frequency_response (int n, int nfreq, const double *mass, int ldm, const double *stiff, int ldk, double alpha, double beta, const double *freq, const c_modal_excite frc, double *modes, double *modeshapes, int ldms, double complex *rsp, int ldr, void *user_data)
 Compute a modal frequency response for a second-order system.
 
void c_dynamic_stiffness_dense (int n, double omega, const double *mass, int ldm, const double *damp, int ldc, const double *stiff, int ldk, double complex *dyn_stiff, int ldd)
 Compute dense dynamic stiffness, K - omega^2 M + i omega C.
 
void c_frf_general_damp_1 (int n, int nfreq, const double *mass, int ldm, const double *damp, int ldc, const double *stiff, int ldk, const double *freq, const c_modal_excite frc, double complex *rsp, int ldr, int *ranks, void *user_data)
 Compute a general-damping frequency response at explicit frequencies.
 
void c_frf_general_damp_2 (int n, int nfreq, double freq1, double freq2, const double *mass, int ldm, const double *damp, int ldc, const double *stiff, int ldk, const c_modal_excite frc, double complex *rsp, int ldr, int *ranks, void *user_data)
 Compute a general-damping frequency response over an evenly spaced interval.
 
double c_compute_modal_damping (double lambda, double alpha, double beta)
 Compute modal damping from Rayleigh coefficients.
 
double c_chirp (double t, double amp, double span, double f1Hz, double f2Hz)
 Evaluate a swept-frequency chirp signal.
 
void c_modal_response (int n, const double *mass, int ldm, const double *stiff, int ldk, double *freqs, double *modeshapes, int ldms)
 Compute modal frequencies and mass-normalized mode shapes.
 
void c_normalize_mode_shapes (int n, double *x, int ldx)
 Normalize mode-shape columns.
 
void c_frf_sweep (int n, int nfreq, c_harmonic_ode fcn, const double *freq, const double *iv, int solver, double complex *rsp, int ldr, const c_frequency_sweep_controls *opts, void *user_data)
 Perform a nonlinear harmonic frequency sweep.
 
void c_set_frequency_sweep_defaults (c_frequency_sweep_controls *x)
 Fill frequency-sweep controls with defaults.
 
void c_evaluate_accelerance_frf_model (int n, int norder, const double *mdl, const double *omega, double complex *h)
 Evaluate an accelerance rational FRF model.
 
void c_evaluate_receptance_frf_model (int n, int norder, const double *mdl, const double *omega, double complex *h)
 Evaluate a receptance rational FRF model.
 
void c_set_iteration_controls_defaults (c_iteration_controls *x)
 Fill nonlinear iteration controls with defaults.
 
void c_fit_frf (int n, int norder, int method, const double *freq, const double complex *rsp, const double *maxp, const double *minp, const c_iteration_controls *controls, double *mdl, c_regression_statistics *stats)
 Fit an FRF model to measured data.
 
void c_siso_frequency_response (int n, int nf, const double *x, const double *y, double fs, int winsize, c_window_function winfun, int method, double *freq, double complex *rsp, void *user_data)
 Estimate a SISO frequency response from input and output records.
 
void c_cross_product (const double x[3], const double y[3], double z[3])
 Compute the cross product of two three-vectors.
 
void c_to_skew_symmetric (const double x[3], double *y, int ldy)
 Form a skew-symmetric matrix from a three-vector.
 
double c_vector_angle (const double x[3], const double y[3])
 Compute the angle between two vectors.
 
double c_scalar_projection (const double x[3], const double y[3])
 Compute the scalar projection of one vector onto another.
 
void c_vector_projection (const double x[3], const double y[3], double z[3])
 Project one vector onto another.
 
double c_vector_magnitude (int n, const double *x)
 Compute a vector magnitude.
 
void c_vector_normalize (int n, double *x)
 Normalize a vector in place.
 
double c_dot_product (int n, const double *x, const double *y)
 Compute a dot product.
 
bool c_is_symmetric (int m, int n, const double *a, int lda)
 Test whether a matrix is symmetric to within a small relative tolerance.
 
void c_siso_model_fit_least_squares (int nsets, int nparams, int neqns, const c_ode_fit fcn, const c_dynamic_system_measurement *x, const double *ic, double *p, int integrator, int ind, const double *maxp, const double *minp, const c_iteration_controls *controls, const c_lm_solver_options *opts, int nconstraints, const double *xc, const double *yc, const c_constraint_equations constraints, int nweights, const double *weights, c_regression_statistics *stats, c_iteration_behavior *info, void *user_data)
 Fit an ODE model to dynamic-system measurements by constrained least squares.
 
void c_set_lm_solver_options_defaults (c_lm_solver_options *x)
 Fill Levenberg-Marquardt options with defaults.
 
int c_alloc_dynamic_system_measurement (int n, c_dynamic_system_measurement *x)
 Allocate one dynamic-system measurement record.
 
void c_free_dynamic_system_measurement (c_dynamic_system_measurement *x)
 Release one dynamic-system measurement record.
 
c_dynamic_system_measurement * c_alloc_dynamic_system_measurement_array (int n, const int *ptsper)
 Allocate an array of measurement records.
 
void c_free_dynamic_system_measurement_array (int n, c_dynamic_system_measurement *x)
 Release an array of measurement records.
 
void c_quaternion_from_array (const double x[4], c_quaternion *q)
 Construct a quaternion from four scalar components.
 
void c_quaternion_from_matrix (const double *x, int ldx, c_quaternion *q)
 Construct a quaternion from a rotation matrix.
 
void c_quaternion_from_angle_axis (double angle, const double axis[3], c_quaternion *q)
 Construct a quaternion from angle-axis data.
 
void c_quaternion_normalize (c_quaternion *q)
 Normalize a quaternion in place.
 
void c_quaternion_add (const c_quaternion *x, const c_quaternion *y, c_quaternion *q)
 Add two quaternions.
 
void c_quaternion_subtract (const c_quaternion *x, const c_quaternion *y, c_quaternion *q)
 Subtract two quaternions.
 
void c_quaternion_multiply (const c_quaternion *x, const c_quaternion *y, c_quaternion *q)
 Multiply two quaternions.
 
void c_quaternion_divide (const c_quaternion *x, const c_quaternion *y, c_quaternion *q)
 Divide two quaternions.
 
void c_quaternion_scale (double x, const c_quaternion *y, c_quaternion *q)
 Scale a quaternion.
 
void c_quaternion_conjugate (const c_quaternion *q, c_quaternion *qc)
 Compute a quaternion conjugate.
 
void c_quaternion_rotate (const c_quaternion *q, const double r[3], double rp[3])
 Rotate a vector using a quaternion.
 
double c_quaternion_abs (const c_quaternion *q)
 Compute the quaternion norm.
 
void c_quaternion_inverse (const c_quaternion *q, c_quaternion *qinv)
 Compute a quaternion inverse.
 
void c_quaternion_to_matrix (const c_quaternion *q, double *r, int ldr)
 Convert a quaternion to a rotation matrix.
 
void c_quaternion_to_angle_axis (const c_quaternion *q, double *angle, double axis[3])
 Convert a quaternion to angle-axis data.
 
void c_quaternion_exp (const c_quaternion *q, c_quaternion *rst)
 Compute the quaternion exponential.
 
void c_quaternion_log (const c_quaternion *q, c_quaternion *rst)
 Compute the quaternion logarithm.
 
void c_quaternion_pow (const c_quaternion *q, double exponent, c_quaternion *rst)
 Raise a quaternion to a real power.
 
double c_quaternion_dot_product (const c_quaternion *x, const c_quaternion *y)
 Compute the quaternion dot product.
 
void c_quaternion_to_roll_pitch_yaw (const c_quaternion *q, double *roll, double *pitch, double *yaw)
 Convert a quaternion to roll, pitch, and yaw angles.
 
void c_plane_normal (const c_plane *pln, double nrm[3])
 Extract a plane normal.
 
void c_plane_from_3_points (const double pt1[3], const double pt2[3], const double pt3[3], c_plane *pln)
 Construct a plane through three points.
 
void c_plane_from_point_and_normal (const double pt[3], const double nrm[3], c_plane *pln)
 Construct a plane from a point and normal.
 
void c_plane_from_points (int n, const double *pts, int ldp, c_plane *pln)
 Fit a plane to point data.
 
void c_flip_plane_normal (c_plane *pln)
 Reverse a plane normal and its equation.
 
void c_line_from_2_points (const double pt1[3], const double pt2[3], c_line *ln)
 Construct a line through two points.
 
void c_line_from_2_planes (const c_plane *p1, const c_plane *p2, c_line *ln)
 Construct the intersection line of two planes.
 
void c_line_from_points (int n, const double *pts, int ldp, c_line *ln)
 Fit a line to point data.
 
void c_evaluate_line_position (const c_line *ln, double t, double x[3])
 Evaluate a point on a line.
 
bool c_is_parallel_vectors (int n, const double *x, const double *y, double tol)
 Test whether two vectors are parallel within a tolerance.
 
bool c_is_parallel_lines (const c_line *x, const c_line *y, double tol)
 Test whether two lines are parallel.
 
bool c_is_parallel_planes (const c_plane *x, const c_plane *y, double tol)
 Test whether two planes are parallel.
 
bool c_is_point_on_plane (const double pt[3], const c_plane *pln, double tol)
 Test whether a point lies on a plane.
 
bool c_is_point_on_line (const double pt[3], const c_line *ln, double tol)
 Test whether a point lies on a line.
 
double c_nearest_point_on_line (const double pt[3], const c_line *ln)
 Find the parameter of the nearest point on a line.
 
double c_point_to_line_distance (const double pt[3], const c_line *ln)
 Compute the distance from a point to a line.
 
double c_point_to_plane_distance (const double pt[3], const c_plane *pln)
 Compute the distance from a point to a plane.
 
void c_vector_plane_projection (const double x[3], const c_plane *pln, double px[3])
 Project a vector onto a plane.
 
void c_point_plane_projection (const double pt[3], const c_plane *pln, double ppt[3])
 Project a point onto a plane.
 
void c_plucker_line_from_2_points (const double pt1[3], const double pt2[3], c_plucker_line *ln)
 Construct a Pluecker line through two points.
 
void c_plucker_line_from_line (const c_line *src, c_plucker_line *ln)
 Convert a line to Pluecker coordinates.
 
void c_plucker_line_from_2_planes (const c_plane *p1, const c_plane *p2, c_plucker_line *ln)
 Construct a Pluecker line from two planes.
 
void c_plucker_line_from_array (const double x[6], c_plucker_line *ln)
 Construct a Pluecker line from six coordinates.
 
void c_plucker_line_mtx_mult (int n, const double *x, int ldx, const c_plucker_line *ln, double *y)
 Apply a matrix to a Pluecker line.
 
void c_plucker_line_to_array (const c_plucker_line *ln, double x[6])
 Convert a Pluecker line to six coordinates.
 
void c_line_common_normal (const c_line *ln1, const c_line *ln2, c_line *ln)
 Compute the common normal of two lines.
 
void c_do_lines_intersect (const c_line *ln1, const c_line *ln2, bool *intersect, double *t1, double *t2, double tol)
 Determine whether two lines intersect and return their parameters.
 
void c_line_from_point_and_vector (const double pt[3], const double v[3], c_line *ln)
 Construct a line from a point and direction.
 
void c_poincare_map (int n, const double *x, const double *y, const double *z, const c_plane *pln, int side, int nbuffer, double *xbuffer, double *ybuffer, double *zbuffer, int *nactual)
 Compute a Poincare section map from sampled trajectories.
 
void c_poincare_map_ode (c_ode_equations fcn, const double tspan[2], int n, const double *iv, int sample_count, const c_plane *pln, int side, int solver, c_poincare_coordinates coordinates, int nbuffer, double *xbuffer, double *ybuffer, double *zbuffer, int *nactual, void *user_data)
 Compute a Poincare section map by integrating an ODE and intersecting uniformly spaced solution samples with a plane.
 
int c_alloc_dh_table (int n, c_dh_table *tbl)
 Allocate a Denavit-Hartenberg table.
 
void c_free_dh_table (c_dh_table *tbl)
 Release a Denavit-Hartenberg table.
 
void c_define_link_csys (const double xim1[3], const double zim1[3], const double zi[3], const double rim1[3], const double ri[3], c_coordinate_system *csys)
 Define a link coordinate system from adjacent geometry.
 
void c_define_csys (const double i[3], const double j[3], const double k[3], const double o[3], c_coordinate_system *csys)
 Define a coordinate system from basis vectors and origin.
 
void c_build_dh_table (int n, const c_coordinate_system *csys, c_dh_table *tbl)
 Build Denavit-Hartenberg parameters from coordinate systems.
 
int c_alloc_serial_linkage (int n, c_serial_linkage *lnk)
 Allocate a serial linkage.
 
void c_free_serial_linkage (c_serial_linkage *lnk)
 Release a serial linkage.
 
void c_build_serial_linkage (int n, const c_binary_link *links, c_serial_linkage *linkage)
 Build a serial linkage from link definitions.
 
void c_serial_linkage_forward_kinematics (int n, const c_serial_linkage *lnk, const double *q, double *T, int ldt)
 Evaluate serial-link forward kinematics.
 
void c_serial_linkage_jacobian (int n, const c_serial_linkage *lnk, const double *q, double *jac, int ldj)
 Evaluate the serial-link Jacobian.
 
void c_serial_linkage_inverse_kinematics (int n, const c_serial_linkage *lnk, const double *qo, const double *trg, int ldt, double *q, c_iteration_behavior *ib)
 Solve serial-link inverse kinematics.
 
int c_alloc_mechanism_link (int nframes, c_mechanism_link *lnk)
 Allocate a multi-frame mechanism link.
 
void c_free_mechanism_link (c_mechanism_link *lnk)
 Release a multi-frame mechanism link.
 
c_mechanism c_create_parallel_linkage (int nlinks, const c_mechanism_link *links, int njoints, const c_joint *joints, int base, int effector, const double *tool, int ldt)
 Create a spatial parallel linkage mechanism.
 
c_mechanism c_create_planar_linkage (int nlinks, const c_mechanism_link *links, int njoints, const c_joint *joints, int base, int effector, const double *tool, int ldt)
 Create a planar parallel linkage mechanism.
 
void c_free_mechanism (c_mechanism obj)
 Release a mechanism handle.
 
int c_mechanism_link_count (c_mechanism obj)
 Return the number of links in a mechanism.
 
int c_mechanism_joint_count (c_mechanism obj)
 Return the number of joints in a mechanism.
 
int c_mechanism_variable_count (c_mechanism obj)
 Return the number of mechanism variables.
 
int c_mechanism_loop_count (c_mechanism obj)
 Return the number of independent loops.
 
int c_mechanism_constraint_count (c_mechanism obj)
 Return the number of constraint equations.
 
int c_mechanism_degrees_of_freedom (c_mechanism obj)
 Return mechanism degrees of freedom.
 
int c_mechanism_actuated_variable_count (c_mechanism obj)
 Return the number of actuated variables.
 
int c_mechanism_space_dimension (c_mechanism obj)
 Return the mechanism spatial dimension.
 
int c_mechanism_link_frame_count (c_mechanism obj, int i)
 Return the frame count for a link.
 
void c_mechanism_link_frame (c_mechanism obj, int i, int k, double *T, int ldt)
 Return a link-frame transform.
 
void c_mechanism_get_configuration (c_mechanism obj, int n, double *q)
 Get the current mechanism configuration.
 
void c_mechanism_set_configuration (c_mechanism obj, int n, const double *q)
 Set the mechanism configuration.
 
void c_mechanism_body_transform (c_mechanism obj, int i, int n, const double *q, double *T, int ldt)
 Evaluate a body transform at a configuration.
 
void c_mechanism_end_effector_transform (c_mechanism obj, int n, const double *q, double *T, int ldt)
 Evaluate the end-effector transform.
 
void c_mechanism_constraints (c_mechanism obj, int n, const double *q, int nc, double *f)
 Evaluate mechanism constraint equations.
 
void c_mechanism_constraint_jacobian (c_mechanism obj, int n, const double *q, double *jac, int ldj)
 Evaluate the mechanism constraint Jacobian.
 
void c_mechanism_solve_configuration (c_mechanism obj, int na, const double *qa, int n, double *q, c_iteration_behavior *ib)
 Solve for a complete mechanism configuration.
 
void c_mechanism_forward_kinematics (c_mechanism obj, int na, const double *qa, double *T, int ldt, c_iteration_behavior *ib)
 Evaluate forward kinematics for a mechanism.
 
void c_mechanism_jacobian (c_mechanism obj, int na, const double *qa, double *jac, int ldj)
 Evaluate a mechanism Jacobian.
 
void c_mechanism_inverse_kinematics (c_mechanism obj, const double *trg, int ldt, int na, double *qa, c_iteration_behavior *ib)
 Solve mechanism inverse kinematics.
 
void c_default_variational_integrator_settings (c_variational_integrator_settings *settings)
 Fill variational-integrator settings with library defaults.
 
void c_variational_integrator_solve (int nbody, const c_rigid_body *bodies, int ntime, double dt, const double *initial_position, const c_quaternion *initial_orientation, const double *initial_velocity, const double *initial_angular_velocity, int nconstraint, c_variational_force force_callback, c_variational_constraint constraint_callback, c_variational_constraint_jacobian jacobian_callback, void *user_data, const c_variational_integrator_settings *settings, double *position, c_quaternion *orientation, double *velocity, double *angular_velocity, double *multipliers, int *converged, int *iterations, int *jacobian_singular, int *completed_steps)
 Integrate rigid bodies directly in maximal coordinates.
 
c_linkage_dynamic_model c_create_serial_linkage_dynamic_model (const c_serial_linkage *linkage, int n, const double *q)
 Create a dynamic model from a serial linkage value.
 
c_linkage_dynamic_model c_create_linkage_dynamic_model (bool planar, int nlinks, const c_mechanism_link *links, int njoints, const c_joint *joints, int base, int nq, const double *q)
 Create a dynamic model directly from parallel/planar linkage descriptors.
 
void c_free_linkage_dynamic_model (c_linkage_dynamic_model obj)
 Release a linkage dynamic-model handle.
 
int c_linkage_dynamic_body_count (c_linkage_dynamic_model obj)
 Return the number of moving rigid bodies in a dynamic model.
 
int c_linkage_dynamic_joint_count (c_linkage_dynamic_model obj)
 Return the number of joints represented by a dynamic model.
 
int c_linkage_dynamic_constraint_count (c_linkage_dynamic_model obj)
 Return the linkage constraint count before any prescribed-motion constraint is added.
 
void c_linkage_dynamic_add_linear_spring (c_linkage_dynamic_model obj, const c_linear_spring *element)
 Add a tension/compression linear spring.
 
void c_linkage_dynamic_add_linear_damper (c_linkage_dynamic_model obj, const c_linear_damper *element)
 Add an axis-only linear viscous damper.
 
void c_linkage_dynamic_add_torsional_spring (c_linkage_dynamic_model obj, const c_torsional_spring *element)
 Add a linear torsional spring to a revolute joint.
 
void c_linkage_dynamic_add_torsional_damper (c_linkage_dynamic_model obj, const c_torsional_damper *element)
 Add a twist-rate damper to a revolute joint.
 
int c_linkage_dynamic_axial_element_count (c_linkage_dynamic_model obj)
 
int c_linkage_dynamic_torsional_element_count (c_linkage_dynamic_model obj)
 
void c_linkage_dynamic_axial_element_results (c_linkage_dynamic_model obj, int nbody, double time, const double *position, const c_quaternion *orientation, const double *velocity, const double *angular_velocity, c_axial_element_result *results)
 Query all axial elements at one state.
 
void c_linkage_dynamic_torsional_element_results (c_linkage_dynamic_model obj, int nbody, double time, const double *position, const c_quaternion *orientation, const double *velocity, const double *angular_velocity, c_torsional_element_result *results)
 Query all torsional elements at one state.
 
void c_linkage_dynamic_solve (c_linkage_dynamic_model obj, int nbody, int nconstraint, const c_variational_integrator_settings *settings, int ntime, double dt, const double gravity[3], const double *body_force, const double *body_torque, int prescribed_body, c_linkage_prescribed_motion prescribed_motion, void *user_data, double *position, c_quaternion *orientation, double *velocity, double *angular_velocity, double *multipliers, int *converged, int *iterations, int *jacobian_singular, int *completed_steps)
 Solve linkage dynamics.
 
void c_linkage_dynamic_joint_reactions (c_linkage_dynamic_model obj, int nbody, int nconstraint, double time, const double *position, const c_quaternion *orientation, const double *velocity, const double *angular_velocity, const double *multipliers, c_joint_reaction *reactions)
 Convert one state's linkage multipliers into joint reaction wrenches.
 
int c_alloc_polynomial (int order, c_polynomial *p)
 Allocate a polynomial.
 
void c_free_polynomial (c_polynomial *p)
 Release a polynomial.
 
int c_alloc_transfer_function (int numer_order, int denom_order, c_transfer_function *tf)
 Allocate a transfer function.
 
void c_free_transfer_function (c_transfer_function *tf)
 Release a transfer function.
 
int c_alloc_state_space_model (int dimension, int n_inputs, int n_outputs, c_state_space_model *mdl)
 Allocate a continuous state-space model.
 
void c_free_state_space_model (c_state_space_model *mdl)
 Release a state-space model.
 
void c_evaluate_transfer_function (const c_transfer_function *tf, int n, const double complex *s, double complex *z)
 Evaluate a transfer function at complex points.
 
void c_transfer_function_poles (const c_transfer_function *tf, int n, double complex *p)
 Compute transfer-function poles.
 
void c_transfer_function_zeros (const c_transfer_function *tf, int n, double complex *z)
 Compute transfer-function zeros.
 
void c_to_ccf_state_space (const c_transfer_function *tf, c_state_space_model *ss)
 Convert a transfer function to controllable canonical state space.
 
void c_to_ocf_state_space (const c_transfer_function *tf, c_state_space_model *ss)
 Convert a transfer function to observable canonical state space.
 
void c_create_state_space_model (int n, int n_out, const double *m, int ldm, const double *b, int ldb, const double *k, int ldk, c_state_space_model *mdl)
 Create a state-space model from mass, damping, and stiffness matrices.
 
void c_create_pid_state_space_model (double kp, double ki, double kd, double tau, const c_state_space_model *plant, c_state_space_model *mdl)
 Create a PID-controlled plant state-space model.
 
void c_transfer_function_multiply (const c_transfer_function *tf1, const c_transfer_function *tf2, c_transfer_function *tf)
 Multiply two transfer functions.
 
void c_scale_transfer_function (double x, const c_transfer_function *tf1, c_transfer_function *tf)
 Scale a transfer function.
 
void c_lti_solve (const c_state_space_model *mdl, const c_ss_excitation u, int n, const double *t, int ndof, const double *ic, int solver, int nout, double *y, int ldy, void *user_data)
 Integrate a continuous state-space model.
 
void c_state_space_poles (const c_state_space_model *mdl, int n, double complex *p)
 Compute state-space poles.
 
void c_state_space_zeros (const c_state_space_model *mdl, int n, double complex *z, int *nz)
 Compute state-space zeros.
 
void c_state_space_transfer_function (const c_state_space_model *mdl, int nin, int nout, int n, const double complex *s, double complex *z, int ldz)
 Evaluate the state-space transfer matrix.
 
double c_beam_element_2d_length (const c_beam_element_2d *elem)
 Compute the length of a 2D beam element.
 
void c_beam_element_2d_stiffness_matrix (const c_beam_element_2d *elem, int rule, double *k, int ldk)
 Compute the 6-by-6 stiffness matrix of a 2D beam element.
 
void c_beam_element_2d_mass_matrix (const c_beam_element_2d *elem, int rule, double *m, int ldm)
 Compute the 6-by-6 mass matrix of a 2D beam element.
 
void c_beam_element_2d_rotation_matrix (const c_beam_element_2d *elem, double *r, int ldr)
 Compute the 6-by-6 rotation matrix of a 2D beam element.
 
void c_beam_element_2d_strain (const c_beam_element_2d *elem, const double displacement[6], double s, double strain[2])
 Compute the strain in a 2D beam element at a natural coordinate.
 
void c_beam_element_2d_stress (const c_beam_element_2d *elem, const double displacement[6], double s, double stress[2])
 Compute the stress in a 2D beam element at a natural coordinate.
 
double c_beam_element_2d_shear_force (const c_beam_element_2d *elem, const double displacement[6], double s)
 Compute the local shear force in a 2D beam element at a natural coordinate.
 
double c_beam_element_2d_bending_moment (const c_beam_element_2d *elem, const double displacement[6], double s)
 Compute the local bending moment in a 2D beam element at a natural coordinate.
 
void c_beam_element_2d_external_force_vector (const c_beam_element_2d *elem, const double q[2], int rule, double f[6])
 Compute the equivalent nodal force vector for a distributed load on a 2D beam element.
 
double c_beam_element_3d_length (const c_beam_element_3d *elem)
 Compute the length of a 3D beam element.
 
void c_beam_element_3d_stiffness_matrix (const c_beam_element_3d *elem, int rule, double *k, int ldk)
 Compute the 12-by-12 stiffness matrix of a 3D beam element.
 
void c_beam_element_3d_mass_matrix (const c_beam_element_3d *elem, int rule, double *m, int ldm)
 Compute the 12-by-12 mass matrix of a 3D beam element.
 
void c_beam_element_3d_rotation_matrix (const c_beam_element_3d *elem, double *r, int ldr)
 Compute the 12-by-12 rotation matrix of a 3D beam element.
 
void c_beam_element_3d_strain (const c_beam_element_3d *elem, const double displacement[12], double s, double strain[4])
 Compute the strain in a 3D beam element at a natural coordinate.
 
void c_beam_element_3d_stress (const c_beam_element_3d *elem, const double displacement[12], double s, double stress[4])
 Compute the stress in a 3D beam element at a natural coordinate.
 
void c_beam_element_3d_shear_force (const c_beam_element_3d *elem, const double displacement[12], double s, double force[2])
 Compute the local shear-force vector in a 3D beam element at a natural coordinate.
 
void c_beam_element_3d_bending_moment (const c_beam_element_3d *elem, const double displacement[12], double s, double moment[3])
 Compute the local moment vector in a 3D beam element at a natural coordinate.
 
void c_beam_element_3d_external_force_vector (const c_beam_element_3d *elem, const double q[4], int rule, double f[12])
 Compute the equivalent nodal force vector for a distributed load on a 3D beam element.
 
void c_assemble_static_system_beam_2d (int gdof, int n, const c_beam_element_2d *elements, int nn, const c_node *nodes, int rule, double *k, int ldk)
 Assemble a dense global stiffness matrix from 2D beam elements.
 
void c_assemble_dynamic_system_beam_2d (int gdof, int n, const c_beam_element_2d *elements, int nn, const c_node *nodes, int rule, double *m, int ldm, double *k, int ldk)
 Assemble dense global mass and stiffness matrices from 2D beam elements.
 
void c_assemble_static_system_beam_3d (int gdof, int n, const c_beam_element_3d *elements, int nn, const c_node *nodes, int rule, double *k, int ldk)
 Assemble a dense global stiffness matrix from 3D beam elements.
 
void c_assemble_dynamic_system_beam_3d (int gdof, int n, const c_beam_element_3d *elements, int nn, const c_node *nodes, int rule, double *m, int ldm, double *k, int ldk)
 Assemble dense global mass and stiffness matrices from 3D beam elements.
 
void c_apply_boundary_conditions_mtx (int n, int nbc, int *gdof, const double *x, int ldx, double *rst, int ldr)
 Apply boundary conditions to a dense matrix by removing the constrained rows and columns.
 
void c_apply_boundary_conditions_vec (int n, int nbc, int *gdof, const double *x, double *rst)
 Apply boundary conditions to a dense vector by removing the constrained entries.
 
void c_restore_constrained_values_dense (int nred, int nbc, int *gdof, const double *x, double *rst)
 Restore the constrained degrees of freedom removed by c_apply_boundary_conditions_vec.
 
void c_apply_displacement_constraint_dense (int dof, double val, int n, double *k, int ldk, double *f)
 Apply a displacement constraint to a single degree of freedom.
 
void c_solve_static_system_dense (int n, const double *k, int ldk, const double *f, double *u)
 Solve the static system K*u = f for a dense stiffness matrix.
 
double c_truss_element_2d_length (const c_truss_element_2d *elem)
 Compute the length of a 2D truss element.
 
void c_truss_element_2d_stiffness_matrix (const c_truss_element_2d *elem, double *k, int ldk)
 Compute the 4-by-4 global stiffness matrix of a 2D truss element.
 
void c_truss_element_2d_mass_matrix (const c_truss_element_2d *elem, int rule, double *m, int ldm)
 Compute the 4-by-4 consistent mass matrix of a 2D truss element.
 
void c_truss_element_2d_rotation_matrix (const c_truss_element_2d *elem, double *r, int ldr)
 Compute the 4-by-4 rotation matrix of a 2D truss element.
 
double c_truss_element_2d_strain (const c_truss_element_2d *elem, const double displacement[4])
 Compute the axial strain in a 2D truss element.
 
double c_truss_element_2d_axial_force (const c_truss_element_2d *elem, const double displacement[4])
 Compute the axial force (positive in tension) in a 2D truss element.
 
void c_truss_element_2d_external_force_vector (const c_truss_element_2d *elem, const double q[2], int rule, double f[4])
 Compute the equivalent nodal force vector for a distributed load on a 2D truss element.
 
double c_truss_element_3d_length (const c_truss_element_3d *elem)
 Compute the length of a 3D truss element.
 
void c_truss_element_3d_stiffness_matrix (const c_truss_element_3d *elem, double *k, int ldk)
 Compute the 6-by-6 global stiffness matrix of a 3D truss element.
 
void c_truss_element_3d_mass_matrix (const c_truss_element_3d *elem, int rule, double *m, int ldm)
 Compute the 6-by-6 consistent mass matrix of a 3D truss element.
 
void c_truss_element_3d_rotation_matrix (const c_truss_element_3d *elem, double *r, int ldr)
 Compute the 6-by-6 rotation matrix of a 3D truss element.
 
double c_truss_element_3d_strain (const c_truss_element_3d *elem, const double displacement[6])
 Compute the axial strain in a 3D truss element.
 
double c_truss_element_3d_axial_force (const c_truss_element_3d *elem, const double displacement[6])
 Compute the axial force (positive in tension) in a 3D truss element.
 
void c_truss_element_3d_external_force_vector (const c_truss_element_3d *elem, const double q[3], int rule, double f[6])
 Compute the equivalent nodal force vector for a distributed load on a 3D truss element.
 
void c_assemble_static_system_truss_2d (int gdof, int n, const c_truss_element_2d *elements, int nn, const c_node *nodes, double *k, int ldk)
 Assemble a dense global stiffness matrix from 2D truss elements.
 
void c_assemble_dynamic_system_truss_2d (int gdof, int n, const c_truss_element_2d *elements, int nn, const c_node *nodes, int rule, double *m, int ldm, double *k, int ldk)
 Assemble dense global mass and stiffness matrices from 2D truss elements.
 
void c_assemble_static_system_truss_3d (int gdof, int n, const c_truss_element_3d *elements, int nn, const c_node *nodes, double *k, int ldk)
 Assemble a dense global stiffness matrix from 3D truss elements.
 
void c_assemble_dynamic_system_truss_3d (int gdof, int n, const c_truss_element_3d *elements, int nn, const c_node *nodes, int rule, double *m, int ldm, double *k, int ldk)
 Assemble dense global mass and stiffness matrices from 3D truss elements.
 
void c_spring_element_2d_stiffness_matrix (const c_spring_element_2d *elem, double *k, int ldk)
 Compute the 4-by-4 global stiffness matrix of a 2D spring element.
 
double c_spring_element_2d_force (const c_spring_element_2d *elem, const double displacement[4])
 Compute the spring force (positive in tension) in a 2D spring element.
 
void c_spring_element_3d_stiffness_matrix (const c_spring_element_3d *elem, double *k, int ldk)
 Compute the 6-by-6 global stiffness matrix of a 3D spring element.
 
double c_spring_element_3d_force (const c_spring_element_3d *elem, const double displacement[6])
 Compute the spring force (positive in tension) in a 3D spring element.
 
void c_damper_element_2d_damping_matrix (const c_damper_element_2d *elem, double *c, int ldc)
 Compute the 4-by-4 global damping matrix of a 2D damper element.
 
double c_damper_element_2d_force (const c_damper_element_2d *elem, const double velocity[4])
 Compute the damper force (positive in tension) in a 2D damper element.
 
void c_damper_element_3d_damping_matrix (const c_damper_element_3d *elem, double *c, int ldc)
 Compute the 6-by-6 global damping matrix of a 3D damper element.
 
double c_damper_element_3d_force (const c_damper_element_3d *elem, const double velocity[6])
 Compute the damper force (positive in tension) in a 3D damper element.
 
void c_mass_element_2d_mass_matrix (const c_mass_element_2d *elem, double *m, int ldm)
 Compute the 2-by-2 mass matrix of a 2D point mass element.
 
void c_mass_element_3d_mass_matrix (const c_mass_element_3d *elem, double *m, int ldm)
 Compute the 3-by-3 mass matrix of a 3D point mass element.
 
void c_assemble_discrete_system_2d (int gdof, int nm, const c_mass_element_2d *masses, int nd, const c_damper_element_2d *dampers, int ns, const c_spring_element_2d *springs, int nn, const c_node *nodes, double *m, int ldm, double *c, int ldc, double *k, int ldk)
 Assemble dense global mass, damping, and stiffness matrices for a 2D system composed of discrete elements.
 
void c_assemble_discrete_system_3d (int gdof, int nm, const c_mass_element_3d *masses, int nd, const c_damper_element_3d *dampers, int ns, const c_spring_element_3d *springs, int nn, const c_node *nodes, double *m, int ldm, double *c, int ldc, double *k, int ldk)
 Assemble dense global mass, damping, and stiffness matrices for a 3D system composed of discrete elements.
 
c_structural_integrator c_create_dense_generalized_alpha_integrator (int n, const double *m, int ldm, const double *c, int ldc, const double *k, int ldk, double rho_infinity)
 Create a dense generalized-alpha integrator for M*a + C*v + K*u = f.
 
void c_free_structural_integrator (c_structural_integrator obj)
 Release a structural integrator handle.
 
void c_structural_integrator_step (c_structural_integrator obj, int n, const double *force_current, const double *force_next, double dt, double *displacement, double *velocity, double *acceleration)
 Advance the state by one time step.
 
void c_structural_integrator_solve (c_structural_integrator obj, int n, int npts, const double *forces, int ldf, double dt, double *displacement, double *velocity, double *acceleration)
 Advance the state through a force history using npts - 1 constant steps.
 

Detailed Description

Public C interface to the DYNAMICS library.

Matrices use column-major storage to match the Fortran implementation. A matrix with m rows and n columns has leading dimension ld and stores element (i, j) at j * ld + i, using zero-based C indices. Link, joint, and frame indices passed to the mechanism API are one-based. Objects returned by an allocation or creation routine remain owned by the caller and must be released with the corresponding c_free_* routine. Unless documented otherwise, pointer arguments must refer to storage large enough for the dimensions supplied to the routine.

Argument errors detected by this interface (for example, an undersized leading dimension or a NULL callback) do not terminate the process. The routine records the error, invokes any handler registered with c_set_error_handler, and returns without computing a result; outputs are then unspecified. Query the error with c_get_last_error. Errors detected deeper inside the Fortran library still terminate the process.

Every callback receives the user_data pointer supplied to the routine that invoked it, allowing callers to pass state without globals.

Typedef Documentation

◆ c_error_handler

typedef void(* c_error_handler) (int code, const char *message, void *user_data)

Error handler callback.

Parameters
codeError code (one of the DYN_*_ERROR constants).
messageNull-terminated description, valid only during the call.
user_dataOpaque pointer supplied to c_set_error_handler.

◆ c_vecfcn

typedef void(* c_vecfcn) (int nvar, int neqn, const double *x, double *f, void *user_data)

Nonlinear vector function callback.

Parameters
nvarNumber of variables.
neqnNumber of equations.
xInput variables.
fOutput residual vector.
user_dataOpaque caller data.

◆ c_modal_excite

typedef void(* c_modal_excite) (int n, double freq, double complex *f, void *user_data)

Modal force callback used by frequency-response routines.

Parameters
nModal count.
freqFrequency.
fOutput modal force.
user_dataOpaque caller data.

◆ c_harmonic_ode

typedef void(* c_harmonic_ode) (int n, double freq, double t, const double *x, double *dxdt, void *user_data)

Harmonic ordinary-differential-equation callback.

Parameters
nState dimension.
freqExcitation frequency.
tTime.
xState vector.
dxdtOutput state derivative.
user_dataOpaque caller data.

◆ c_window_function

typedef double(* c_window_function) (int n, int bin, void *user_data)

Window function callback used by SISO frequency analysis.

Parameters
nWindow length.
binZero-based sample index.
user_dataOpaque caller data.
Returns
Window coefficient.

◆ c_constraint_equations

typedef void(* c_constraint_equations) (int n, int neqn, int nparam, const double *xg, const double *fg, const double *xc, const double *p, double *fc, void *user_data)

Constraint callback used by least-squares system identification.

Parameters
nData-set index or count.
neqnEquation count.
nparamParameter count.
xgGeneral input values.
fgGeneral constraint values.
xcConstraint inputs.
pModel parameters.
fcOutput constraint residuals.
user_dataOpaque caller data.

◆ c_ode_fit

typedef void(* c_ode_fit) (int n, int nparam, const double *mdl, double t, const double *x, double F, double *dxdt, void *user_data)

ODE model callback used by system identification.

Parameters
nState dimension.
nparamParameter count.
mdlModel parameters.
tTime.
xState vector.
FInput or forcing value.
dxdtOutput state derivative.
user_dataOpaque caller data.

◆ c_ss_excitation

typedef void(* c_ss_excitation) (int n, double t, double *u, void *user_data)

State-space input callback used by c_lti_solve.

Parameters
nInput count.
tTime.
uOutput input vector.
user_dataOpaque caller data.

◆ c_ode_equations

typedef void(* c_ode_equations) (int n, double t, const double *x, double *dxdt, void *user_data)

Ordinary-differential-equation callback.

Parameters
nState dimension.
tIndependent variable (time).
xState vector.
dxdtOutput state derivative.
user_dataOpaque caller data.

◆ c_poincare_coordinates

typedef void(* c_poincare_coordinates) (int n, double t, const double *x, double coordinates[3], void *user_data)

Poincare section coordinate callback.

Maps a sampled ODE state onto the coordinates intersected with the section plane.

Parameters
nState dimension.
tTime at which the state was sampled.
xState vector.
coordinatesOutput 3-element [x, y, z] section coordinates.
user_dataOpaque caller data.

◆ c_variational_state

◆ c_variational_force

typedef void(* c_variational_force) (const c_variational_state *state, double *force, double *torque, void *user_data)

External force and torque callback for variational integration.

Parameters
stateCurrent maximal-coordinate state. The pointed-to state and its arrays are read-only and valid only for the duration of the callback.
forceOutput world-frame force array with shape 3-by-body_count in column-major storage.
torqueOutput body-frame torque array with shape 3-by-body_count in column-major storage.
user_dataOpaque caller data supplied to the solve routine.

◆ c_variational_constraint

typedef void(* c_variational_constraint) (const c_variational_state *state, int nconstraint, double *value, void *user_data)

Holonomic constraint callback for variational integration.

Parameters
stateTrial maximal-coordinate state at which the constraints are evaluated. The pointed-to data are valid only during the callback.
nconstraintNumber of scalar constraint equations.
valueOutput array of nconstraint residual values.
user_dataOpaque caller data supplied to the solve routine.

◆ c_variational_constraint_jacobian

typedef void(* c_variational_constraint_jacobian) (const c_variational_state *state, int nconstraint, double *jacobian, int ldj, void *user_data)

Reduced constraint-Jacobian callback.

Parameters
stateCurrent maximal-coordinate state at which the Jacobian is evaluated.
nconstraintNumber of Jacobian rows and scalar constraints.
jacobianOutput nconstraint-by-(6*body_count) matrix in column-major storage. Columns for each body are ordered as three translations followed by three local quaternion-tangent rotations.
ldjLeading dimension of jacobian; equal to nconstraint.
user_dataOpaque caller data supplied to the solve routine.

◆ c_linkage_prescribed_motion

typedef double(* c_linkage_prescribed_motion) (double t, void *user_data)

Prescribed planar-link angular motion callback.

Parameters
tSimulation time.
user_dataOpaque caller data supplied to c_linkage_dynamic_solve.
Returns
Prescribed absolute world-z angle in radians.

◆ c_mechanism

typedef void* c_mechanism

Opaque handle to a closed-loop mechanism.

Create handles with c_create_parallel_linkage or c_create_planar_linkage, and release them with c_free_mechanism.

◆ c_linkage_dynamic_model

typedef void* c_linkage_dynamic_model

Opaque linkage dynamic-model handle.

Create with c_create_serial_linkage_dynamic_model or c_create_linkage_dynamic_model and release with c_free_linkage_dynamic_model.

◆ c_structural_integrator

typedef void* c_structural_integrator

Opaque linear structural time-integrator handle.

Create with c_create_dense_generalized_alpha_integrator and release with c_free_structural_integrator.