I have two meshes which I want to align. I need to put the (bottom surface of the) cylinder on top of the box as shown. I got the normal vectors of both surfaces (v1,v2).
How do I calculate the needed rotation for the cylinders surface to face the exact opposite direction of the top of the box?
I'm grateful for any advice.
Thanks in advance
Related
How can I get a 3x3 matrix representing all the transformations (scale,rotation) to apply to an image drawn on a canvas given 4 points x1,y1...x4,y4 representing the ROI(sub-image) that I want to zoom and rotate on?
The first coordinates x1,y1 should be transformed to the top left corner(0,0) of the canvas and x2,y2 to the bottom right corner of the canvas(canvas.width, canvas.height).
Thank you very much for your help!
Here is a drawing of the concept. My smalish QR script gives me the 4 points of the (perspectivly skewed) rectangle. I now all points and therefore all angles. I can determine the center by some basic geometry, but I dont get how I could calculate the vector of the direction the rect/plane is facing (red line in the diagramm). I'm looking to achieve some kind of minimal AR effect.
Thank you.
This is related to the arc drawn by HTML5 canvas "arcTo" function. I need to calculate the two tangent points of a circle with the radius R and two lines given by three points Q(x0,y0), P(x1,y1) and R(x2,y2).
The sketch explains the problem more. I need to find the tangent points A(xa,ya) and B(xb,yb). Note that the center of the circle is not given. Please help.
This is a question of solving a triangle with 2 known angles and one known side. Label the centre of the circle C, then the side you know is BC (or AC if you want). Angle PBC (CAP) is a right angle. The line CP bisects the angle RPQ.
Not all such triangles have a solution.
I'm making a game where the player is an upright capped cylinder, and the world is axis aligned bounding boxes. Given this, how could I check if the cylinder is intersecting a box?
Thanks
It's mostly a 2D problem.
For each AABB, test that the vertical dimensions of the cylinder overlap the vertical dimensions of the AABB. If so, then the test reduces to a 2D case, otherwise, there's no collision.
Then, in the 2D case you need to find if your circle intersects a rectangle... and I'll just refer you to here:
Circle-Rectangle collision detection (intersection)
Imagine a photo, with the face of a building marked out.
Its given that the face of the building is a rectangle, with 90 degree corners. However, because its a photo, perspective will be involved and the parallel edges of the face will converge on the horizon.
With such a rectangle, how do you calculate the angle in 2D of the vectors of the edges of a face that is at right angles to it?
In the image below, the blue is the face marked on the photo, and I'm wondering how to calculate the 2D vector of the red lines of the other face:
example http://img689.imageshack.us/img689/2060/leslievillestarbuckscor.jpg
So if you ignore the picture for a moment, and concentrate on the lines, is there enough information in one of the face outlines - the interior angles and such - to know the path of the face on the other side of the corner? What would the formula be?
We know that both are rectangles - that is that each corner is a right angle - and that they are at right angles to each other. So how do you determine the vector of the second face using only knowledge of the position of the first?
It's quite easy, you should use basic 2 point perspective rules.
First of all you need 2 vanishing points, one to the left and one to the right of your object. They'll both stay on the same horizon line.
alt text http://img62.imageshack.us/img62/9669/perspectiveh.png
After having placed the horizon (that chooses the sight heigh) and the vanishing points (the positions of the points will change field of view) you can easily calculate where your lines go (of course you need to be able to calculate the line that crosses two points: i think you can do it)
Honestly, what I'd do is a Hough Transform on the image and determine a way to identify the red lines from the image. To find the red lines, I'd find any lines in the transform that touch your blue ones. The good thing about the transform is that you get angle information for free.
Since you know that you're looking at lines, you could also do a Radon Transform and look for peaks at particular angles; it's essentially the same thing.
Matlab has some nice functionality for this kind of work.