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.
Related
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.
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.
I'm using VisualSfM to build the 3D reconstruction of a scene. Now I want to estimate the depthmap and reproject the image. Any idea on how to do it?
If you have the camera intrinsic matrix K, its position vector in the world C and an orientation matrix R that rotates from world space to camera space, you can iterate over all pixels x,y in your image and perform:
Then, find using ray tracing, the minimal t that causes the ray to intersect with your 3D model (assuming it's dense, otherwise interpolate it), so that P lies on your model. The t value you found is then the pixel value of the depth map (perhaps normalized to some range).
I have 2 sets of points that are restricted to live on the 3D unit sphere, call them {pi} and {qi} (I'll assume correspondence is known). The goal is to register one set to the other, through rotations and translations. Typically I would have used a transformation of the form:
P = RQ + T
where R is a rotation matrix and T a translation vector.
But in this case there is an extra constraint that all points must live on the sphere, how can I include this condition.
Assuming the sets are 'rigid', so you can slide and rotate the whole set on the sphere, but can not change distances between points within a set, all possible transformations are rotations.
Whenever you rotate the set relative to some axis, points move in planes perpendicular to the axis. So all displacements are vectors normal to the axis vector. So each two displacement vectors should make a vector product parallel to the axis vector.
Now, if you already know the correspondence between P and Q points, calculate displacement vectors di from each qi to a corresponding pi and calculate some vector products:
di × dj = (pi - qi) × (pj - qj)
If they have directions close enough to each other, you can assume you have the rotation axis.
Now for each pair or pi,qi find a point ti on an axis such that the PQT triangle is normal to the axis. The angle at the T vertex defines the rotation to slide qi to pi. If all respective angles are equal, you're done. Otherwise you'll have to seek some approximate solution...
I would like to find a solution for taking a rotation represented as a matrix and then resetting one of it's components. Basically I want to be able to multiply a vector by this matrix and get a direction that is rotation around x and z axis and be constant along the y axis (up). I want to take object rotation and get the vector that represents gravity but in object local space and disregarding the yaw. So I want to reset the yaw.
I don't want to convert this to euler angles. I would prefer using a quaternion or doing some sequence of operations on the rotation matrix directly in order to avoid possible bugs with certain angles.
Ok, so I have the follwoing:
btTransform t;
mBody->getMotionState()->getWorldTransform(t);
btMatrix3x3 trans = t.getBasis().inverse();
btVector3 up = (trans * btVector3(0, 1, 0));
I realized that if I used quaternion then I got completely wrong results (why?). Now I'm getting a vector in object space that represents up vector in world space. BUT I want to rotate this vector so that it represents global up vector in object space WHEN MODEL HAS ZERO rotation around Y axis. So I have to somehow rotate this vector back. How?
You can use quaternion swing twist decomposition with passed "Y" axis. It will decompose quaternion to rotation around Y axis and rotation around axis that is perpendicular to Y.
It is described here, in my answer.
Component of a quaternion rotation around an axis