Finding Rotation and Translation between three coordinate systems - camera

If we have three coordinate systems namely A, B, and C and we know the [R|t] from A to B and A to C. Then how can we find the [R|t] between B and C?

From B to C is from B to A to C, so you need to invert the first transformation and combine it with the second.
I assume that by [R|t] you mean the rotation matrix plus translation vector. It might be easier to consider these two as a single square matrix operating on homogeneous coordinates. For planar operations that would be a 3×3 matrix, for 3d operations it would be 4×4. That way you can use regular matrix inversion and multiplication to describe your combined result.

Related

Getting 2 values of focal length when finding Intrinsic camera matrix (F not Fx,Fy)?

The following image is the example that was given in my computer vision class. Now I cant understand why we are getting 2 unique values of f. I can understand if mxf and myf are different, but shouldn't the focal length 'f' be the same?
I believe you have an Fx and a Fy. This is so that the the matrix transforms on f can scale f in two directions x and y. IIRC this is why you get 2 f numbers
If really single f wanted, it should be modeled in the camera model used in calibration.
e.g. give the mx,my as constants to the camera model, and estimate the f.
However, perhaps the calibration process that obtained that K was not that way, but treated the two elements (K(0,0) and K(1,1)) independently.
In other words, mx and my were also estimated in the sense of dealing with the aspect ratio.
The estimation result is not the same as the values of mx and my calculated from the sensor specifications.
This is why you got 2 values.

Sampling specific points on open3d surface

I have successfully created a surface from a pointcloud in open3d
mesh, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(inlier_cloud, depth=9)
Now I want to be able to pick two points A, B on the surface and uniformly sample n points on the surface in between A, B along with their normal vectors.
Is there some way how to do it in open3d? (or in any other library, maybe PyVista?)
Thanks

finding pivot point of two 3D transformations

I need to find out what the degrees of freedom are between two arbitrary geometries that may be linked to eachother. for instance a hinge consisting of two parts. I can simulate the motion of the two parts, and I figured that if I fix one of the parts in place, i can deduce what the axes and point of rotation is for the second moving part is from the transformation in each timestep.
I run into some difficulties calculating this (my vector algebra is ok, my (numpy) math skills less so)
How I see it is I have two 4x4 transformation matrices for each timestep, the previous position/orientation of the moving part (A) and the current position/orientation (A')
then the point of rotation can be found by by calculating the transformation matrix B that transforms A into A' which is I believe
B = inverse(A) * A'
and then find the point that does not change under transformation by B:
x = Bx
Is my thinking correct and if so, how do I solve this equation?

How to convert relative GPS coordinates to a "local custom" x, y, z coordinate?

Let's say I know two persons are standing at GPS location A and B. A is looking at B.
I would like to know B's (x, y, z) coordinates based on A, where the +y axis is the direction to B (since A is looking at B), +z is the vertically to the sky. (therefore +x is right-hand side of A)
I know how to convert a GPS coordinate to UTM, but in this case, a coordinate system rotation and translation seem needed. I am going to come up with a calculation, but before that, will there be some codes to look at?
I think this must be handled by many applications, but I could not find so far.
Convert booth points to 3D Cartesian
GPS suggest WGS84 so see How to convert a spherical velocity coordinates into cartesian
Construct transform matrix with your desired axises
see Understanding 4x4 homogenous transform matrices. So you need 3 perpendicular unit vectors. The Y is view direction so
Y = normalize(B-A);
one of the axises will be most likely up vector so you can use approximation
Z = normalize(A);
and as origin you can use point A directly. Now just exploit cross product to create X perpendicular to both and make also Y perpendicular to X and Z (so up stays up). For more info see Representing Points on a Circular Radar Math approach
Transfrom B to B' by that matrix
Again in the QA linked in #1 is how to do it. It is simple matrix/vector multiplication.

How should I implement a class representing a geometric plane?

In a given domain, I need to represent mathematical plane in 3D space, so I intend to create a Plane3D class.
I would also have Point3D, Vector3D, Ray3D, and so on. Main use case would be to test/find line-plane intersections, line-plane angles, and other geometric operations.
Question is:
Which would be a good, canonical, computation-friendly way to implement plane definition in a class?
Most obvious candidates would be "point-normal" form, with six numeric parameters (three coordinates for the point, three for the vector) and "general (algebraic) form", with four numeric parameters (one coefficient per coordinate and one constant). Is one of them computationally preferrable?
Also, is there any open source, high level 3D Geometry library already implementing this class, which would be worth taking a look for inspiration?
OBS: Since .NET has System.Windows.Media.Media3D library with some useful classes, most probably I'll implement this in C#, taking advantage of Point3D and Vector3D structs, but I think the question is language-agnostic.
I'd go for what you call algebraic form. A point (x,y,z) is on a plane (a,b,c,d) if a*x+b*y+c*z+d=0.
To intersect that plane with a line spanned by (x1,y1,z1) and (x2,y2,z2), compute s1=a*x1+b*y1+c*z1+d and s2=a*x2+b*y2+c*z2+d. Then your point of intersection is defined by
x=(s1*x2-s2*x1)/(s1-s2)
y=(s1*y2-s2*y1)/(s1-s2)
z=(s1*z2-s2*z1)/(s1-s2)
To compute the angle between a line and a plane, simply compute
sin(α)=(a*x+b*y+c*z)/sqrt((a*a+b*b+c*c)*(x*x+y*y+z*z))
where (a,b,c) represents the normal vector in this representation of the plane, and (x,y,z) is the direction vector of the line, i.e. (x2-x1,y2-y1,z2-z1). The equation is essentially a normalized dot product, and as such is equivalent to the cosine between the two vectors. And since the normal vector is perpendicular to the plane, and sine and cosine differ by 90°, this means that you get the sine of the angle between the line and the plane itself.