Finding the visible area of a point [closed] - c++

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.

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.

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.

Calculate The object angle(face) having two points? [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 7 years ago.
Improve this question
C++, I want calculate the angle of the direction of the two points.
Here is a picture which shows the two points and the direction of how to get the angle of the direction?
p1 - start point. p2 - direction point. me need direction angle(facing?) from p1 to p2
#include <cmath>
// ...
double angle = atan2(p2.y - p1.y, p2.x - p1.x);
// ...
If you want to, you can also make sure that p1 != p2, because if it is then you'll get a domain error.

How to interpolate 3D points computed from a Kinect to get a ball trajectory? [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 8 years ago.
Improve this question
I'm getting 3D points from the Kinect via OpenNI. Let's say I have :
X = [93.7819,76.8463,208.386,322.069,437.946,669.999]
Y = [-260.147,-250.011,-230.717,-211.104,-195.538,-189.851]
Z = [958,942,950,945,940,955]
That's the points I was able to catch from my moving ball. Now I would like to be able to compute something like an interpolation or least square with those points to know the trajectory of the ball. I can then know where the ball is going and where it will hit the wall.
I'm not sure of which mathematical tool to use and how to translate it in C++. I've seen lots of resources for 2D interpolation (cubic,...) or least squares, but it seems that it's harder for 3D or I missed something maybe.
Best regards
EDIT : the question is marked as too broad by moderators, so I will reduce the scope with the responses I got : if I use 2D polynomial regression with the 3 plans separately (thx yephick), what can I use in C++ to implement it ?
For what you are interested in there's hardly any difference between 3D and 2D.
All you do is work with planes independently (XY plane, XZ plane, and YZ plane). This will reduce the complexity significantly and allow you to "draw" much simpler diagrams on a piece of paper when you work on this problem.
Once you figured the coordinates in each of the planes it is quite trivial to not only reconcile the coordinates into a 3D space but also provides an added benefit of error checking. For example an X coordinate found in XY plane should match (or be "close enough") to the same X coordinate found in XZ plane.
If the accuracy is not too critical you don't even need to go higher than the first power of polynomial approximation, using just a simple plain-old arithmetical average of the two consequential points.
You can use spline interpolation to create a smooth trajectory.
If not in the "mood" to implement it yourself, a quick google search will give you open source libraries like SINTEF's SISL that have such functionallity.

Matrix Transformations and Texture mapping coordinates confusion (Beginner) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was doing some questions on matrix transformations and texture mapping and I came across two questions for which I dont know how to get the answer. The answer is highlighted with red colour.
(These can be implemented in C++ but before I do it I just wanted to familiarize myself with transformations first)
For matrix transformation shouldnt it have -1 (top right of the matrix) for the translation instead of 0
EDIT: STILL NEED AN ANSWER TO THE SECOND QUESTION
My second query is that I am not sure how they got the y coordinate for point D
Answering the first question:
The resultant image is compressed into half along the x-axis and elongated to twice the length across Y-axis.
Scaling Matrix is what will be the answer. Scaling matrix is a diagonal matrix with elements {X-scaling, Y-scaling, 1}.
Now,
| 0.5 0 0 |
| 0 2 0 |
| 0 0 1 |
is a typical scaling matrix. It scales the x-axis by 0.5 (that is it stretches(compresses) the x-axis into half). This is noticeable in Matrix(1,1).
THe scaling across Y-direction is given in Matrix(2,2). The 2 over there implies, the Y-axis is elongated 2 times.
NOTE:
In this question there is no translation involved. Notice that simple scaling makes it seem like translation.
Found the answer to the second question.
The corner above point B must have the y-coordinate 1, since otherwise you wouldn't see the bottom face. Hence for the point D you need the y-coordinate 2. If you take the line from B to the corner point to D, then the textre image is repeated two times.