How to get rotation in quaternion from a model view matrix? [closed] - c++

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed yesterday.
This post was edited and submitted for review yesterday.
Improve this question
I am trying to get the rotation in quaternion relative to the world coordinates.
mat4 mat(1);
mat *= rotate(radians(45.0f), vec3(0, 1, 0));
quat q = conjugate(toQuat(mat));
log(degrees(eulerAngles(q)));
In this code, the matrix rotates 45 degrees around y-axis, but q represents a -45 degrees rotation around y-axis. How can I find the correct rotation?

Related

smooth out corners of a 3-point line strip [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have a line strip defined by 3 points, each having an x and y coordinate.
I'm trying to smooth out the middle (point 2) corner as shown in the picture below:
the gray line is the original line strip and the black one is the smoothed-out one.
The smoothed out area should be constant across multiple values (as in it is not dependent on length of the line between p1 and p2 or p2 and p3).
I've originally been using bezier curves and a simple spline, however that did not do the trick since the smooth curve was obviously not same across multiple values.
How can I do this?
Pick 2 points on each line that are the same distance to the corner. On those points draw two lines at right angles to the lines you already have (normal vectors pointing bottom left). They will cross at a point which will be the center of a circle, part this circle will then be the smoothed corner.

Histogram calculation for rotation invariant local binary pattern in opencv c++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have been working on a opencv project that requires calculation of histogram for rotation invariant local binary pattern.I checked github and bytefish git repos but cant find what i am looking for.
Exactly what i want to say is that once i find the lbp image of any video frame or image, how to make it rotation invariant lbp and find its histogram as texture feature that can be further used for training or classification.
Can someone tell me how to exactly find the histogram for rotation invariant LBP and histogram for uniform rotation invariant LBP in opencv c++.
Thankyou!

Finding the visible area of a point [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
There's a triangle and a point lying outside it. We need to find the summary length of triangle sides that are visible from the point.
In this case the answer is AB+BC.
As input there are coordinates of the points.
So the question is how to solve it in C++?
P.S. In my opinion we need to find ρ(P;each of the points) and watch if this distance intersect with any of the triangle's sides. Then choose the two farthest points, which met the condition, and find the sum of the side(s).
Let's define an order for the triangle vertices. Let it be counter-clockwise. Your triangle is ACB (clockwise order would be ABC).
The point sees an edge if it's located in the right semi-plane that the edge defines.
This formula:
res = (y2 - y1)*(px - x1) - (x2 - x1)*(py - y1)
gives info about what semi-plane is (px,py) relative to (x1,y1)-(x2,y2) segment. Just get the sign of res.
You analize the three segments of the triangle an get those that the point is on the right side.
Choosing the other order changes the sign.

Need help on visual odometry formular [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
Hey there I try to do a realtime visual odometry system for a monocular camera.
Now I'm looking for an equation to describe 3d points movement in 2d vectors. While researching I came across a very interesting looking equation. I'm refering to page 22. It basically makes a simplification under the assumption of a relatively small time step. But now I'm struggeling about the image coordinates x and y. It's said that x would be sth like x=(px-px0) and y=(py-py0). When I understand it right p0 is the center of rotation. But if this is the case the whole formular would make no sense for my case cause I would need a prior knowledge of the center of rotation. Which is based on the translation again.
So maybe can help understanding it or maybe point me to a better way to do it.
To use this equation, you must have calibrated your camera (with a pinhole model), so you have a set of distortion coefficients, a focal distance and the principal point, which is the intersection of the optical axis with the image plane, as illustrated here: http://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html.
In the equation you mention, x and y coordinates are in pixels after distortion correction and relative to the center of projection, not the center of rotation. So, the px0 and py0 you are looking for, are the coordinates of the principal point, that is, cx0 and cy0 using the naming convention of the link above.

How to project point cloud on a plane with OpenGL? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I am trying to present a point cloud and its projection with OpenGL on the plane normal to the line connecting the two most distant points. I have succeed in presenting the point cloud on the scene with an orthonormal system. I have found the two farthest point in the cloud. And I found the plan on which I projected.
I tried to make this projection but envin.
I tried with the transformation matrices as GL_PROJECTION but envin.
Can someone give me hand?
You can calculate the coordinates of the projected points by mathematical formulas, then draw them with OpenGL.
Take a look at this link
You can drop a perpendicular from each point to your found plane, and compute its foot point on the plane. Then draw another point there.