I am on a team making some image interpreting software.
I have made a real world distance measuring system that is fairly accurate for a given plane(~0.3% difference with real life), but when i asked my senior coworker how i could make it real world accurate, he told me that i needed to calculate the affine parameters. I asked for more detail, but I'm not sure he quite knew it either, either way, he didn't go into more detail with me. After talking to a few different people about it, i am certain that it is what i need to be doing.
I have tried reading a lot of articles on how affine transformations work, but matrix math has always been a big weakness for me and its been far too long since my calculus 3 classes. Can someone help me understand how you calculate affine transformations with object oriented logic? because all these articles i am finding go way over my head when they start including nabla and matrixes and such in their equations(its greek to me). I can learn how to use those things(im assuming i will need to) but it all just seems very convoluted to me. Help in understanding this topic would be greatly appreciated.
I don't know if it helps but i am programming in c# and start with 6 measurements of the sides and diagonals of a quadrilateral that the user inputs on the image.
I'll just give some general information, since more information about your particular problem would be needed to give more specific advice. Also I won't go into details about matrix multiplication, or about how to construct a matrix representing a rotation etc, since I'm sure there will be a library in whatever language you're using (ie C#) that takes care of these.
In this case, after choosing an origin and coordinate system, we'd represent points in space by 3-dimensional vectors; eg (0, 0, 0) would represent the origin, and (1, 0, 0) a point 1 unit from the origin in the positive x direction.
Now imagine rotating everything 90 degrees around the y-axis. (1, 0, 0) would move to (0, 0, -1), while (0, 1, 0) wouldn't move. It turns out there is a matrix representing this rotation, namely
0 0 1
0 1 0
-1 0 0
This means that if you multiply this matrix by a vector, you'll get the result of rotating the vector (eg multiplying by (1, 0, 0) gives (0, 0, -1), and multiplying by (0, 1, 0) gives (0, 1, 0)).
Your matrix library will have a function MultiplyMatrixVector (or similar name) to do this, and a function RotationY (or similar name) to construct the matrix representing a rotation around the y-axis by a given angle. It will probably represent the matrix by an array of 9 numbers read from the rows of the matrix, [0, 0, 1, 0, 1, 0, -1, 0, 0] (or perhaps read from the columns, [0, 0, -1, 0, 1, 0, 1, 0, 0]; you'll find out which from the documentation or trial-and-error).
One advantage of representing rotations by matrices is that if you want to do several rotations in sequence, you can just multiply the corresponding matrices. Again your library will have a function like MultiplyMatrices to do this. Note that generally the result depends on the order of the rotations. Again check the library documentation to know which rotation happens first when you use MultiplyMatrices(A, B).
In practice, to answer a question like "If I rotate 30 degrees around the y-axis, then 60 degrees around the z-axis, what happens to the point (2, 3, 4)?", you would do something like this:
Ry = RotationY(30);
Rz = RotationZ(60);
R = MultiplyMatrices(Rz, Ry);
result = MultiplyMatrixVector(R, Vector3D(2, 3, 4));
The next part seems strange but we'll see how it's useful later: we're going to represent points in space by 4-dimensional vectors. Given a point in 3D like (2, 3, 4), we can get a 4D vector by just tacking a 1 on the end, ie (2, 3, 4, 1). Conversely a 4D vector (x, y, z, w) represents the point (x/w, y/w, z/w) in 3D. Note that (2, 3, 4, 1) and (4, 6, 8, 2) both represent the same point (2, 3, 4) in 3D.
Now we'll use 4x4 matrices to represent transformations. We can use all the 3x3 rotation matrices discussed previously by fitting them into a 4x4 matrix in the following pattern:
* * * 0
* * * 0
* * * 0
0 0 0 1
For example, the y-axis rotation above is now represented by
0 0 1 0
0 1 0 0
-1 0 0 0
0 0 0 1
As before, we use MultiplyMatrixVector to apply a transformation to a point, and MultiplyMatrices to do transformations in sequence. Why are 4D vectors useful? We can represent some new transformations. For example, panning everything 1 unit in the direction of the x-axis (a translation) is represented by
1 0 0 1
0 1 0 0
0 0 1 0
0 0 0 1
More importantly we can represent a projection. Imagine your eye is at the origin, and you are looking through a viewport in the plane at z=1. Each point in 3D projects to some point in the viewport plane. It can be computed by applying the matrix
1 0 0 0
0 1 0 0
0 0 0 1
0 0 1 0
and then dropping the z coordinate. For example, consider the point p = (2, 3, 4), represented by the 4D vector (2, 3, 4, 1). Applying the matrix gives (2, 3, 1, 4), representing the 3D point (2/4, 3/4, 1/4). Dropping the z coordinate, p projects to (2/4, 3/4) in the plane. This simulates how a camera maps points in 3D space to points in a 2D image.
The projection can be more simply described without matrices - it just sends (x, y, z) to (x/z, y/z). The advantage of using matrices is that it can be easily combined with other transformations. eg if the camera is not located at the origin or pointing in the z direction, you can account for this by multiplying by some rotation and translation matrices (again, being careful to get them in the right order).