update_primal_from_dual

compas_ags.ags.update_primal_from_dual(xy, _xy, free, i_nbrs, ij_e, _C, line_constraints=None, target_lengths=[], target_vectors=[], leaves=[], kmax=100)

Update the coordinates of the primal diagram using the coordinates of the corresponding dual diagram. This function apply to both sides, i.e. it can be used to update the form diagram from the geometry of the force diagram or to update the force diagram from the geometry of the force diagram.

Parameters:
xyarray-like

XY coordinates of the vertices of the primal diagram.

_xyarray-like

XY coordinates of the vertices of the dual diagram.

freelist

List of free vertices.

i_nbrslist of list of int

Vertex neighbours per vertex.

ij_edict

Edge index for every vertex pair.

_Csparse matrix in csr format

The connectivity matrix of the force diagram.

line_constraintslist, optional

Line constraints applied to the free nodes. Default is an None in which case no line constraints are considered.

target_lengthslist, optional

Target lengths / target forces of the edges. Default is an empty list, which considers that no target lengths are considered.

target_vectorslist, optional

Target vectors of the edges. Default is an empty list, which considers that no target vectors are considered.

leaveslist, optional

The leaves of the primal diagram. Default is an empty list, which considers that no leaves are considered.

kmaxint, optional

Maximum number of iterations. Default is 100.

Returns:
None

The vertex coordinates are modified in-place.

Notes

This function should be used to update the form diagram after modifying the geometry of the force diagram. Or to update the force diagram geometrically to become reciprocal to the form diagram. The objective is to compute new locations for the vertices of the primal diagram such that the corrsponding lines of the primal and dual diagram are parallel while any geometric constraints imposed on the primal diagram are satisfied. Note that form, and force can assume position of primal and dual interchagable.

The location of each vertex of the primal diagram is computed as the intersection of the lines connected to it. Each of the connected lines is based at the connected neighbouring vertex and taken parallel to the corresponding line in the dual diagram.

For a point \(\mathbf{p}\), which is the least-squares intersection of K lines, with every line j defined by a point \(\mathbf{a}_{j}\) on the line and a direction vector \(\mathbf{n}_{j}\), we can write

\[\mathbf{R} \mathbf{p} = \mathbf{q}\]

with

\[\mathbf{R} = \displaystyle\sum_{j=1}^{K}(\mathbf{I} - \mathbf{n}_{j}\mathbf{n}_{j}^{T}) \quad,\quad \mathbf{q} = \displaystyle\sum_{j=1}^{K}(\mathbf{I} - \mathbf{n}_{j}\mathbf{n}_{j}^{T})\mathbf{a}_{j}\]

This system of linear equations can be solved using the normal equations

\[\mathbf{p} = (\mathbf{R}^{T}\mathbf{R})^{-1}\mathbf{R}^{T}\mathbf{q}\]