Three.js How to slerp quaternion to Pathline? - three.js

image:enter image description here
My purpose is to make these cubes rotate along the red line on the left, and the angle of each square is evenly interpolated.
These are some squares I created while using Quaternion.slerp. Obviously they are incorrect. Is there any way?

I'm glad I figured it out myself.
The solution is not an algorithm but an some Angle and some transformations.
enter image description here

Related

How do I find the corners of a plane in 3d space if I know three points

Apologies in advance for my feeble maths.
I'm trying to be able to find the corners of a plane in space based on the equation of that plane. Here's what I know. I know three points on the plane and I know where they fall in the 2d coordinate space of the plane (x,y) and where they are in 3d space. I know the width and height of the plane and I can now calculate the equation of the plane. The plane sits on the inside of a large sphere that surrounds the origin so, in theory, it should more or less face where the camera is (though in my diagram it doesn't face the origin as it's just for illustrative purposes)
But it's not clear to me how I can use that to figure out another point. One thought I had was to find the transform that moves the plane parallel to the xy axis and rotate it round one of the points (so it stays in the same place), find the position of the new point, and then rotate it by the inverse of that transform. But it's not clear to me how I would find that transform matrix or how to use it. Could I do this using the normal and vector maths? I understand what normals are, but I'm fuzzy about how to use them.

Image warping algorithm with a specified vector as distortion direction

I'm studying image warping and I'm unsure how I would proceed to do a simple image warping by specifying something like a direction vector, as in the following picture:
(image reference)
What's the algorithm to do that?
Here's what I thought and here's the question:
I believe a vector should be specified if I want to distort the image as above: the source pixel will go in the vector specified position, but how do the "surrounding pixels" follow that point?

Captured image viewpoint changing

i have a picture that captured from a fixed position [X Y Z] and angle [Pitch Yaw Roll] and a focal length of F (i think this information is called camera matrix)
i want to change the captured picture to a different position like it was taken in up position
the result image should be like:
in fact i have picture taken from this position:
and i want to change my picture in a way that it was taken in this position:
i hope that i could express my problem.
thnx in advance
It can be done accurately only for the (green) plane itself. The 3D objects standing onto the plane will be deformed after remapping, but the deformation may be acceptable if their height is small relative to the camera distance.
If the camera is never moving, all you need to do is identify on the perspective image four points that are the four vertices of a rectangle of known size (e.g. the soccer field itself), then compute the homography that maps those four points to that rectangle, and apply it to the whole image.
For details and code, see the OpenCV links at the bottom of that Wikipedia article.

Algorithm to find a square shape in an image?

Suppose I have an image with, say, a circle and a square. Is there a way to find the square given the matrix of the image? (there is only one square, and time is not really an issue).
Thanks.
Let's divide all points into "lit" and "dark".
Look for points which are lit, and the points above and below are also lit. Those are likely to be a part of an edge.
Similarly: if a point (x,y) is lit and points (x+1,y), (x+2,y) are also lit, but (x-1,y) and (y-1,y) are dark, and analogously in the Y-direction, then you've most likely found an upper-left corner. And so on. In this way you can find the corners and then find the square from them - seems to be a simple approach.
Something like this?
for (x,y of every black pixel) {
#those methods should return true if the lines length is more than one pixel
if (hasLineToRight(x,y)&&hasLineToBottom(x,y)) {
otherx=highestXOfLineToRight();
othery=highestYOfLineToBottom();
if (isLine(x,y,x,othery)&&isLine(x,y,otherx,y)) {
addBoxToList(x,y,otherx,othery);
}
}
}
You propably want to use the box with the highest width and height values.
If the square in the image is perfect, check that there is a border in the expected position. The pseudocode in thejh's answer should work fine.
What about flood filling starting at random points until you found your rectangle ?

Is there an algorithm for solving such projection reconstruction geometric problem?

We have a grid with red squares on it. Meaning we have an array of 3 squares (with angles == 90 deg) which as we know have same size, lying on the same plane and with same rotation relative to the plane they are lying on, and are not situated on same line on plane.
We have a projection of the space which contains the plane with squares.
We want to turn our plane projection with squares so that we would see it like it's facing us, in general we need a formula for turning each point of that original plane projection so that it would be facing us like on the image below.
What formulas can be used for solving such problem, how to solve it, has any one faced something like this before?
This is a special case of finding mappings between quadrilaterals that preserve straight lines. These are generally called homographic transforms. Here, one of the quads is a square, so this is a popular special case. You can google these terms ("quad to quad", etc) to find explanations and code, but here are some for you.
Perspective Transform Estimation
a gaming forum discussion
extracting a quadrilateral image to a rectangle
Projective Warping & Mapping
ProjectiveMappings for ImageWarping by Paul Heckbert.
The math isn't particularly pleasant, but it isn't that hard either. You can also find some code from one of the above links.

Resources