# How to fit an object of constant size based on measurements to known points

I'm looking for a mathematical solution for solving where the base of a camera crane (ie a constant square or rectangle of known dimensions) is with measurements to known points. This seems to be a relatively simple geometry problem but I'm having a tough time with it... The workflow is as follows:

1-In 3d software, I have very accurate positions of points in the environment. 2-The crane base moves, and I need to make my computer crane in the identical position. 3-I go to each corner, and use a laser measuring tool to get the distance from that corner to a known survey point. 4-Currently, I'm visualizing the measurements with circles and by hand moving/rotating the box until each corner touches part of the circle, hence the only solution for where those four corners could be based on the measurements....

I've been researching Euclidean plane movements and vector algebra, but any push in the right direction would be much appreciated as this seems like it should be fairly straightforward....The attached image perhaps does a better job of explaining than I do....Oops nevermind I need a 10 reputation or something to post it....Thanks! Casey

-
Do your fixed survey points and your movable rectangle all lie in a plane? Or, saying it another way, is this a 2D problem or a 3D problem? – bubba Mar 29 '13 at 4:45
Hi bubba thanks for responding ... The survey points are very much 3d as they represent the environment and have lots of height variation...However the crane/rectangle will always be on the floor, hence taking one of the three axis out of the problem... It's as if 4 strings were each attached to one corner of a square and then all 4 were pulled taught. We know how long the strings are, where the points holding them are, and the size of the square. – casey Mar 29 '13 at 5:41
My guess is that this problem usually doesn't have a solution. If you had three survey points, you'd be OK. Having 4 of them over-constrains the problem. Here's a way to think about it: – bubba Mar 29 '13 at 10:07
Ignore the previous comment. Typing before thinking. Here's a way to think about the problem: at each survey point, you have a distance, r (the length of the attached "string"). Construct a sphere of radius r centered at the survey point. You know that one corner of the plate has to lie on this sphere. Similarly, the other three corners of the plate have to lie on three other spheres. If you had three survey points and the plate was infinitely small, this would just be the standard triangulation problem, which can be solved just by intersecting 3 spheres. Your problem is a lot harder, though. – bubba Mar 29 '13 at 10:15
I'm still not sure I understand the role of the "floor". But anyway ... suppose you intersect the four spheres with the "floor" plane. You get four circles. The corners of the plate have to lie on these 4 circles. That problem seems over-constrained -- it usually won't have a solution. – bubba Mar 29 '13 at 10:20

Following the remarks above, let's assume that we have only three survey points, instead of four. At each survey point, we construct a sphere, using the known "string length" distance as the radius. We intersect the three spheres with the "floor" plane to get three circles. Let's say that the $i$-th circle has center point $C_i = (x_i, y_i)$ and radius $r_i$ for $i=1,2,3$.

We can represent the location of the square base plate by a corner point $P_1 = (x,y)$ and an orientation angle $\theta$. Here, $x$, $y$ and $\theta$ are the unknowns that we need to calculate. Suppose the plate has side length $k$. Then the corners of the plate adjacent to $P_1$ are $$P_2 = (x + k\cos\theta, y + k\sin\theta)$$ $$P_3 = (x - k\sin\theta, y + k\cos\theta)$$

After some re-ordering, if neccessary, we can express the known constraints by the equations $$\text{dist}(P_i, C_i) = r_i \quad \text{for } i=1,2,3$$. These equations just say that the point $P_i$ lies on the circle centered at $C_i$. We can then write these equations out in full, in terms of the unknowns $x$, $y$ and $\theta$. We get: $$(x - x_1)^2 + (y - y_1)^2 = r_1^2$$ $$(x + k\cos\theta - x_2)^2 + (y + k\sin\theta - y_2)^2 = r_2^2$$ $$(x - k\sin\theta - x_3)^2 + (y + k\cos\theta - y_3)^2 = r_3^2$$ These three equations can be solved to get $x$, $y$ and $\theta$. This is easier said than done, though. How to do it ... I don't see any clever algebraic approach, but maybe someone else can suggest one, or maybe a computer algebra system like Mathematica or Maple could find one. Alternatively, if you have a good CAD system that has a "sketch constraint solver", you can probably get it to solve this problem for you. If neither of those approaches work, then you'd need to use a numerical equation solver.

Here's a solution produced by using the constraint solving capabilities of a CAD system:

And here's another solution (with different survey points) that just uses plain distance constraints instead of circles:

-
Bubba this is great.. I am using a software called Maya that is largely used in the VFX industry but is very capable of CAD style work . It also has a programming language similar to C. I'll code this on Monday and post the results if all turns out well. Thanks! – casey Mar 30 '13 at 3:47
I don't think Maya has any constraint solving capability, but you can probably drag the plate around until it looks about right. I used a big-time CAD system that does support constraint solving to make the picture shown. – bubba Mar 30 '13 at 6:15