Algorithm used by a CAD software to copy drawings

65 Views Asked by At

On CAD software it is possible to copy a drawing $A$ with points, lines, ... (with UCS A) to a drawing $B$ (with UCS B) specifying a origin point on drawing $A$ and a destination point on drawing $B$.

For example on drawing $A$ there are points $A_1 (A_{1x}, A_{1y}, A_{1z})$ and point $A_2 (A_{2x}, A_{2y}, A_{2z})$ besides there is a UCSA (CAD define this with A origin $OA_x, OA_y, OA_z$ and $2$ unit vectors for $X$-axis and $Y$-axis directions: Link.

On drawing $B$ there are points $B_1 (B_{1x}, B_{1y}, B_{1z})$ and a UCSB (CAD define as UCSA).

On CAD I can copy $A_2$ from drawing $A$ to drawing $B$ using $A_1$ as origin and $B_1$ as destination. CAD software will use the UCSA and UCSB to transform the point before copy.

My question is: which algorithm the CAD software use to do it?

2

There are 2 best solutions below

0
On

Usually, coordinate systems are related by a change of origin and isotropic rescaling (and/or change of unit),

$$\begin{cases}x'=sx+p,\\y'=sy+q\end{cases}$$

or a similarity (if there is a rotation in between)

$$\begin{cases}x'=ux+vy+p,\\y'=vx-uy+q.\end{cases}$$

You can determine the coefficients by taking enough pairs of corresponding points, giving their coordinates in both frames and solving the equations for the unknown coefficients.

When geographic coordinates on a large scale are involved, the transformations are much more complex.

Similar equations hold for 3D. The rotation is expressed by a $3\times3$ orthogonal matrix.

4
On

So the first user coordinate system UCSA has origin $a=OA$, and two unit vectors, all in world coordinates.

I assume these are orthogonal unit vectors $u_1$ and $u_2$, so the missing $u_3$ is simply the vector product $u_1 \times u_2$.

The transformation $T_{WA}$ from world coordinates to UCSA coordinates then has the properties: $$ T_{WA}(a) = 0 \\ T_{WA}(u_i) = e_i \\ $$ Thus the world coordinates origin vector $a$ turns into the local coordinates vector $0$ and the unit vectors (in world coordinates) turn into the canonical unit vectors, so for homogeneous coordinates we have $$ \begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix} = \begin{bmatrix} A^{-1} & 0 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} I & -a \\ 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix} $$ where $A^{-1}$ is the inverse of the $3 \times 3$ matrix $A$ with $$ A = (u_1-a, u_2-a, u_3-a) $$ The transformation $T_{WB}$ from world coordinates to UCSB would be constructed in a similar fashion.

Coordinates from UCSA to UCSB then might be transformed via: $$ T_{AB} = T_{WB} \, T_{WA}^{-1} $$