Computing point projections on a system that can have his axis rotated

55 Views Asked by At

I have a system which should measure the bending of some pins based on a reference position. The pins are placed on a PCB which is placed on a support in order to make the inspection. The PCB does not fit perfectly into the support and the PCB might have different rotations within some small range, depending on how the PCB is placed on the support. I have some fixed elements on the board that I can use to measure the displacement of the board due to rotation like the white square in the top left corner of the PCB. PCB image

However, the displacement of the white square is not proportional with the displacement of the pins (the center of rotation is around the center of the PCB, and the white square and the pins have different positions on the board).

I have tried to switch from the image coordinate system to the white square coordinate system (a system which has the origin in the center of the white square) and measure the pins positions as the distance from the origin of the system (the center of the white square) and the projection of the pin coordinates onto the 2 axes. However, when I compute those values using the same board, but with the PCB rotated I do not obtain the same values. I have the following point coordinates: First Image: White Square Center: (575.39, 981.55) Pin Center: (63.63, 2347.62)

Second Image: White Square Center: (565.7, 1013.43) Pin Center: (76.18, 2389.43) First PCB position Second PCB position

I computed the angle of rotation as the difference between two angles: the first angle is the tangent of the slope determined by the center of the white square in the first image and a static point I chose from the image, and the second angle is the tangent of the slope determined by the center of the white square in the second image and the same static point.

What am I missing?

1

There are 1 best solutions below

0
On

With the help of MATHEMATICA

With the command

images = {Import["https://i.stack.imgur.com/w7exM.jpg"], 
          Import["https://i.stack.imgur.com/Job1X.jpg"]}
matches = ImageCorrespondingPoints @@ images

we have in matches the found corresponding points that can be depicted with the help of command

Show[ListPlot[matches[[1]]], ListPlot[matches[[2]], PlotStyle -> Red]]

enter image description here

After that, the commands

transform[p_, t_, a_] := RotationMatrix[a].(p - t)
obj = Sum[Norm[transform[matches[[1, k]], {x0, y0}, a] - matches[[2, k]]], {k, 1, Length[matches[[1]]]}];
Minimize[obj/Length[matches[[1]]], {a, x0, y0}]

furnished the result

$$ \{2.48961,\{a\to 0.0158511,x_0\to -22.1583,y_0\to 40.8739\}\} $$

where $a$ is the rotation angle, and $(x_0,y_0)$ is the due translation.