# Function Reference

 NOTE: Use the help and doc functions in the command window for more information on each function (e.g., ">> help mdcdemo" or ">> doc mdcdemo").

## INPUT_CONTACT_PAIRS_GEOMETRIC_DATA

Syntax: `INPUT_CONTACT_PAIRS_GEOMETRIC_DATA` Script with the data of the system of bodies and associated surfaces is given by a matrix of (M parameters) x (N contact pairs). Note that the evaluation of the minimum distance function is performed, independently, for each contact pair. Alternatively, input can be provided from an *.xls file (see documentation).

## INPUT_NEWTON_RAPHSON_INITIALIZATION

Syntax: `INPUT_NEWTON_RAPHSON_INITIALIZATION` Script with the data necessary to initialize the iterative method of Newton-Raphson: initial approximation to the solution and residual resolution tolerance.

## INPUT_VISUALIZATION_DATA

Syntax: `INPUT_VISUALIZATION_DATA` Script with the visualization options for the graphical interpretation of minimum distance calculation and contact detection between ellispoids.

## mdcdemo

Syntax: `mdcdemo` Minimum distance calculation examples with ellipsoid surfaces.

## MINIMUM_DISTANCE_CALCULATION

Syntax: ```[d, qk, q_G, n_OP, n_OQ, t_OQ, b_OQ, number_iterations, t_NR] = MINIMUM_DISTANCE_CALCULATION(CPSData, NRMDATA, VISDATA)``` Minimum distance calculation performed for a pair of ellipsoidal surfaces.

## Closest_Candidate

Syntax: ```[qk_, q_G_, min_d] = Closest_Candidate(qk, r_Oalpha, r_Obeta, A_Oalpha, A_Obeta, r_alphai, r_betaj, A_alphai, A_betaj)``` Selection of the closest pair of points given the approximated solution.

## Globalize_Vector

Syntax: `vG = Globalize_Vector(rl1, A1, rl2, A2, ... , rlN, AN)` Converts a vector expressed in a local coordinate system to global coordinates.

## product_of_matrices

Syntax: `A = product_of_matrices({A1, ... , AN})` Multiplies a sequence of square matrices.

Syntax: `coeff = redimension_quadric_coefficients(dimensioned_coefficients)` Recalculates the surface dimensions to implicit quadric coefficients

## rotation_angle_axis

Syntax: `R = rotation_angle_axis(theta, u)` The formula recieves an angle of rotation given by theta and a unit vector, u, that defines the axis of rotation.

## COORDINATE_SYSTEM_ORIENTATIONS

Syntax: `COORDINATE_SYSTEM_ORIENTATIONS` Script that reads the data of the orientation matrices of the local referential systems.

## COORDINATE_SYSTEM_POSITIONS

Syntax: `COORDINATE_SYSTEM_POSITIONS` Script that reads the data of the position vectors of the local referential systems.

## SURFACE_DATA

Syntax: `SURFACE_DATA` Script that reads the data of the surface coefficients (canonical form) and the surface normal types.

## Binormal_Jacobian

Syntax: `b_jacob = Binormal_Jacobian(coefficients, ntype, n, v, sign_aux)` Analytical expression of the binormal vector Jacobian.

## EVALUATION_GEOMETRIC_CONSTRAINTS

Syntax: ```[Phi, Phi_q, n_OP, n_OQ, v_OQ, t_OQ, b_OQ] = EVALUATION_GEOMETRIC_CONSTRAINTS (Qi_canon_coeff, Qj_canon_coeff, ntype_i, ntype_j, r_Oalpha, r_Obeta, A_Oalpha, A_Obeta, r_alphai, r_betaj, A_alphai, A_betaj, qk)``` System of geometric constraints that express the common normal concept.

## Householder_Matrix

Syntax: `H = Householder_Matrix(v)` Householder matrix of a given non-null vector.

## Householder_Vector

Syntax: `[v, sign_aux] = Householder_Vector(n)` Auxiliary vector that the defines the hyperplane of the desired reflection operation.

## Implicit_Canonical_Function

Syntax: `F = Implicit_Canonical_Function(coefficients, Point)` Implicit quadric surface expression.

## NEWTON_RAPHSON_INITIALIZATION_DATA

Syntax: `NEWTON_RAPHSON_INITIALIZATION_DATA` Script that reads both the approximate initial solution (local vector) and solution precision (tolerance). If no approximate solution is provided, an estimate based on the surface dimensions and centroid locations is calculated.

## Normal_Function

Syntax: `n = Normal_Function(ntype, coefficients, Point)` Normal vector of a quadric surface.

## RESOLUTION_SYSTEM_NONLINEAR_EQUATIONS

Syntax: ```[d, qk, q_G, n_OP, n_OQ, t_OQ, b_OQ, number_iterations] = RESOLUTION_SYSTEM_NONLINEAR_EQUATIONS (Qi_canon_coeff, Qj_canon_coeff, ntype_i, ntype_j, r_Oalpha, r_Obeta, A_Oalpha, A_Obeta, r_alphai, r_betaj, A_alphai, A_betaj, qk, tolerance)``` Newton-Raphson method to solve the system of geometric constraints.

## Tangent_Jacobian

Syntax: `t_jacob = Tangent_Jacobian(coefficients, ntype, n, v, sign_aux)` Analytical expression of the tangent vector Jacobian.

## Algebraic_Separation_Condition

Syntax: ```status = Algebraic_Separation_Condition(coeff_canon_i, coeff_canon_j, r_Oalpha, r_Obeta, A_Oalpha, A_Obeta, r_alphai, r_betaj, A_alphai, A_betaj)``` Separation condition for contact detection of ellipsoids.

## Bounding_Spheres

Syntax: `status = Bounding_Spheres(coeff_canon_i, coeff_canon_j, r_Oalpha, r_Obeta, r_alphai, r_betaj)` Simple proximity query based on enclosing spheres that circumscribe the quadric surface domain.

## Visualization Module/

Syntax: `r = Generic_Quadric_Parametrization(coefficients, azimuth, zenith)` Calculation of the radial coordinate of the surface vertices.

Syntax: `[X,Y,Z] = Quadric_Surface_Mesh_Vertices(r, phi, theta)` Calculation of the surface vertices for quadric polygonization.

## VISUALIZATION_DATA

Syntax: `VISUALIZATION_DATA` Script to read the visualization options.

## VISUALIZATION_MINIMUM_DISTANCE_CALCULATION

Syntax: ```VISUALIZATION_MINIMUM_DISTANCE_CALCULATION(Qi_canon_coeff, Qj_canon_coeff, r_Oalpha, r_Obeta, A_Oalpha, A_Obeta, r_alphai, r_betaj, A_alphai, A_betaj, angle_resolution_i, angle_resolution_j, q_G, n_OP, n_OQ, t_OQ, b_OQ)``` Graphical output of the contact detection results.