Getting initial quaternion for a rigid body - rotation

I have a rigid body whose centre of mass is located at position p relative to origin of fixed global reference frame. ux,uy and uz are three orthogonal unit vectors relative to origin of the fixed global reference frame. These unit vectors represent the local coordinate frame of the rigid body. The local coordinate frame follows linear and rotational motion of the rigid body.
How can I build an initial quaternion for this rigid body in its current orientation ?

"ux,uy and uz are three orthogonal unit vectors relative to origin of the fixed global reference frame."
It is exactly the 3x3 rotation matrix. You can just convert from this 3x3 matrix to quaternion, using good known implementation.

Related

Transforming a 3D plane onto a 2D coordinate system

Say I have a set of points from a sensor which are all within a margin of error on a 2D plane somewhere in the 3D space. How would I go on about transforming the coordinates of the points onto a 2d coordinate system, so that for example the convex hulls of the points or the distances between the points don't change?
Assuming you know the equation of the plane (otherwise you can fit it by least-square or other), construct a new coordinate frame as follows:
get the normal vector,
form the cross product with an arbitrary vector having a different direction;
form the cross product of the normal and the second vector,
normalize all three and name the new axis z, x, y.
This creates an orthonormal basis to which you will transform the points. This corresponds to a rigid transform, that preserves all distances. You can drop the z to get the orthogonal projections of the points to the plane.

How to compute 3D rotation matrix by user movement of control point

I have a projected view of a 3D scene. The 2D points are computed by multiplying the 3D points in homogenous coordinates by a view matrix (which includes a translation and rotation) and a perspective matrix. I want to allow the user to move control points which describe the three axes, and update the rotation matrix based on this.
How do I compute the new rotation matrix given a change in projected 2D coordinates, assuming rotation around the origin? Solving for the position of the end of the single axis has a large degeneracy in the set of possible, but maybe solving for rotation in the axes perpendicular to the moved axis might work.

Estimating tilt angles of a body around three arbitrary axis

I know a rotation matrix (or quaternion) of a body in starting position and in end position. The body was tilted in between around three vectors which are known. Is there a way to estimate the angles the body was tilted around these vectors just by knowing the end orientation of the body?
If body rotation is limited in given time period (for example, it does not accomplish two turnovers etc) and direction changes smoothly, then you can consider using of SLERP - spherical linear interpolation.
If you have initial tilt vector p0 (consisting of direction cosines) and ending p1, you can use geometric SLERP to get direction cosines as components of interpolated direction vector

how to calculate camera extrinsic parameters from three known dimensions in the target plane

My question is as follows.
A single camera (constant in both position and orientation) is applied to monitor the motion of a far-away planar target.
The intrinsic parameters including focal length, sensor resolution, principal point, are known. The lens distortion is not considered.
In the world system, three dimensions about the target (in a plane) are known.
I wonder whether it is enough to determine the camera extrinsic parameters. If it is, how to calculate it?
Many thanks.
I think you can first use corresponding points x(image points) and X(object points) to determine the projection matrix P:
x = PX
then run interpretation of P to derive interior and exterior matrix:
P = H1 [I|0] H2
where H1 is 3x3 interior matrix and H2 is 4x4 exterior matrix.
Since you already know interior parameters, I think you can use them to adjust H2 to get a proper result.
Anyway, this method is still lack of high accuracy and need further improvement.

Transform XY plane entities to an arbitrary plane

I have a profile entity in XY plane. I have to do an extrusion along a vector. So I have to bring the profile entity perpendicular to the extrusion vector. Extrusion vector can be a arbitrary one (Xi+Yj+Zk). Could you please provide some idea about vector base manipulation to bring the profile perpendicular to the extrusion vector?
Update
......
Profile in XY plane
Global up vector : (0,0,1)
Extrusion vector : (Xe,Ye,Ze)
Local right = Extrusion vector x Global up vector = (x1,y1,z1)
Local Left = Extrusion vector x Local right = (x2,y2,z2)
I assume I have to rotate the plane twice about Local right and Local Left.
So the angle is calculated for Local right = Atan(Xe.Y/Xe.Z) and the entity is rotated about Local right by calculated angle. and it is working fine
My question is how to calculate the angle for Local Left ?
If I summarize, I have to do the opposite of this one (Mapping coordinates from plane given by normal vector to XY plane)
If you have your extrusion vector and one reference vector you can cross multiply them to retrieve your 2D planes' right vector in 3D space.
I usually use the global up vector as my reference. So your extrusion vector cross multiplied with global up will result in a local right vector. Another cross multiply between your extrusion vector and your new local right vector will result in a local up vector.
Once you get both your local right and local up vectors, those will be your planes X and Y vectors in 3D space.

Resources