I have read a lot about projective geometry and cross ratio, but I don´t get a clue. Here is the problem:
I have four aligned points in a projective coordinate system: a, b, c, d
Something like this: a-------b--c------------d
The cross ratio should now be:
crossRatio = dst(ac)/dst(bc) / dst(ad)/dst(bd)
dst(ac) means the distance from point a to point c.
The result is e.g.: crossRatio=3,25.
I also have the length of dst(bc)=30cm in the real world. But since the points lie on a projective plane (see http://en.wikipedia.org/wiki/Cross-ratio) I think I cannot determine the lengths of all the distances just like that.
So what does this cross ratio mean and how can I use it for measurements of lengths in projective geometry?I just get no picture how it all works together.
Edit: I rewrote the question (because of a downvote before. And please next time tell me WHAT is wrong and can be improved). Sorry for unclear description, I hope it is a bit better now.
I posted the question in math.stackexchange in a bit different way and.... found out the answer my self after a decent amount of time. Look here, if interested.
answer
Related
I'm working on constraining an IK program so that the normal vector in the end-effector frame is parallel to a known vector in the world-frame, when both are projected to the xy-plane. My initial thought was to use an AddAnglesBetweenVectorsConstraint, but that only allows me to specify the total angle between vectors, and no difference between the different axes. Is there currently a way in Drake to do this?
Edit: it turns out that this was not exactly the problem I needed to solve. In my answer below, I describe the real problem I was solving.
It seems that AddOrientationConstraint will do what you need? If not, then you could accomplish the same with adding two PositionConstraints; I do precisely that in the interactive IK example in the notes for this chapter: https://manipulation.csail.mit.edu/trajectories.html .
Turns out, you can do what I wanted to do using an AddAnglesBetweenVectorsConstraint, I just misdescribed my problem. Specifically, what I really wanted was to do was enforce that the y-axis in the end effector frame (where z-axis is the direction of the end-effector, and the x-axis is straight up in said frame) was perpdinicular both to the z-axis in the world frame and the known vector in the world-frame. This is exactly what AddAngleBetweenVectorsConstraint, and it worked very nicely.
I'd like to draw the 3-simplex which encloses some random points in 3D. So for example:
pts <- rnorm(30)
pts <- matrix(pts, ncol = 3)
With these points, I'd like to compute the vertices of the 3-simplex (irregular tetrahedron) that just encloses these points. Can someone suggest a package/function that will do this? All manner of searching for simplex-related material is dominated by answers that relate to using simplices for other purposes, of which there are many. I just want to compute one and draw it. Seems simple, but I don't seem to know the relevant keywords for what I need.
If nobody can find a suitable package for this, you'll have to settle for doing it yourself, which isn't so difficult if you don't require it to be the absolute tightest fit. See this question over at mathexchange.
The simplest approach presented in this question seems to me to be translating the origin so that all points lie in the positive orthant (i.e, all point dimensions are positive) and then projecting the points to lie within the simplex denoted by each unit vector. To get this simplex in your original coordinate system you can take the inverse projection and inverse translation of the points in this simplex.
Another approach suggested there is to find the enveloping sphere (which you can for instance use Ritter's algorithm for), and then find an enveloping simplex of the sphere, which might be an easier task depending what you are most comfortable with.
I think you're looking for convhulln in the geometry package, but I'm no expert, so maybe that isn't quite what you are looking for.
This problem is different from testing if one rect is in another rect.
Known information is the sides length of two rects.
How to calculate if one rect can be put into another rect?
This is a great question! If and only if one of these conditions is satisfied does a smaller rectangle with sides p and q (p >= q) fit completely into a larger rectangle with sides a and b (a >= b):
or
See this for reference.
So if we had variables a, b, p, q, we could check if such a rectangle arrangement would be possible by evaluating:
(p <= a && q <= b) || (p > a &&
b >= (2*p*q*a + (p*p-q*q)*sqrt(p*p+q*q-a*a)) / (p*p+q*q))
EDIT: Thanks to #amulware for posting this alternate version in his comment:
The first check one would do is of course whether the rectangle fits inside the other in either of the axis aligned orientations.
If not, the only option for it to fit is diagonally, but there might actually be many angles for which it fits, the difficulty is, not just guessing but indeed calculating a possible angle, if one exists.
Now, notice that if the inner rectangle does indeed fit diagonally, then you can rotate it until two if its opposite corners touch either both the top and bottom edge of the outer rectangle, or the left and right. (In your diagram more or less the first.)
In that case you already know that you have fit it inside in that one dimension(in the example, the y-axis). You then have to calculate the bounding width of the inner rectangle in the other dimension and check that against the width of the outer box.
There might be a smarter algorithm out there for this, but I am 100% sure that what I describe works. Let me know if you can figure out the math for this yourself(if you think this is a good solution), if not, I might have a go at it later. I wonder if my algorithm can be implemented completely without trig functions...
EDIT:
Ok now, I could not resist...
Here is the math I did to solve the problem as outlined above:
(Sorry, only in image form, I hope my handwriting is readable.)
I would be happy if someone could check my math. I do not see anything wrong with any of the steps right now, but it is always better to have someone else check.
(And of course: Use this at your own risk.)
If anyone finds anything wrong with this algorithm, please let me know and I will fix it as soon as possible.
Also I would be highly interested to see if anyone has a better solution, involving less complicated math. Maybe a vector based approach?
Well, it looks like A.R.S. solution is true, still I'll try to post my solution, it's harder, but it'll let you to build a concrete embedding of one rectangle into another (if possible).
Let us suppose that a>b and p > q. Solution is obvious if a > p and b > q. The problem can also be solved if a<p and b>q. Take a look at the attached photo, in it you'll need only last system of inequalities (if you interested you can look how it was derived)
All you need is to make sure that last system of inequalities has a solution lying between 0 and 1. To do it you need to solve each inequality as equation (as usual quadratic equation). If there are no solution (that's improbable) the solution of inequality is whole real line. If equation has two (maybe equal) solutions t_1 and t_2 the solution of inequality is segment [-infinity, t_1] united with [t_2, infinity]. After you got solutions of both inequalities you should intersect them. Now we should recollect that t is cos of an angle (between 0 and pi/2), so inequality should have solutions between 0 and 1. In that case second rectangle can be embedded into first one. And if you take e.g. t_1 (smaller root of equations) you can build a concreate embedding of rectangles.
You can weed out the two simple cases fairly easily:
If the larger dimension of the second is smaller than the larger dimension of the first, and if the same is true for the smaller dimensions, then the second fits inside.
If the larger dimension of the second is greater than the hypotenuse of the first, then the second will not fit in the first.
The hard part is working out whether it can fit in at an angle such as in your sketch. I don't know of a simple formula -- it probably requires a plug-and-chug solution.
Might be a good question for the Mathematics Stack Exchange site.
Added: I'm not 100% sure if this, but I think that if the hypotenuse of the second is smaller than the hypotenuse of the first then it will fit.
Oops: Nope -- I'll take that back. But if the hypotenuse of the second is larger than the hypotenuse of the first it won't fit.
sorry for posting this in programing site, but there might be many programming people who are professional in geometry, 3d geometry... so allow this.
I have been given best fitted planes with the original point data. I want to model a pyramid for this data as the data represent a pyramid. My approach of this modeling is
Finding the intersection lines (e.g. AB, CD,..etc) for each pair of adjacent plane
Then, finding the pyramid top (T) by intersecting the previously found lines as these lines don’t pass through a single point
Intersecting the available side planes with a desired horizontal plane to get the basement
In figure – black triangles are original best fitted triangles; red
and blue triangles are model triangles
I want to show that the points are well fitted for the pyramid model
than that it fitted for the given best fitted planes. (Assume original
planes are updated as shown)
Actually step 2 is done using weighted least square process. Each intersection line is assigned with a weight. Weight is proportional to the angle between normal vectors of corresponding planes. in this step, I tried to find the point which is closest to all the intersection lines i.e. point T. according to the weights, line positions might change with respect to the influence of high weight line. That mean, original planes could change little bit. So I want to show that these new positions of planes are well fitted for the original point data than original planes.
Any idea to show this? I am thinking to use RMSE and show before and after RMSE. But again I think I should use weighted RMSE as all the planes refereeing to the point T are influenced so that I should cope this as a global case rather than looking individual planes….. But I can’t figure out a way to show this. Or maybe I should use some other measure…
So, I am confused and no idea to show this.. Please help me…
If you are given the best-fit planes, why not intersect the three of them to get a single unambiguous T, then determine the lines AT, BT, and CT?
This is not a rhetorical question, by the way. Your actual question seems to be for reassurance that your procedure yields "well-fitted" results, but you have not explained or described what kind of fit you're looking for!
Unfortunately, without this information, your question cannot be answered as asked. If you describe your goals, we may be able to help you achieve them -- or, if you have not yet articulated them for yourself, that exercise may be enough to let you answer your own question...
That said, I will mention that the only difference between the planes you started with and the planes your procedure ends up with should be due to floating point error. This is because, geometrically speaking, all three lines should intersect at the same point as the planes that generated them.
I have a 3D closed mesh car object having a surface made up
triangles. I want to calculate its volume, center of volume and inertia tensor.
Could you help me
Regards.
George
For volume...
For each triangular facet, lookup its corner points. Call 'em P,Q,R.
Compute this quantity (I call it "partial volume")
pv = PxQyRz + PyQzRx + PzQxRy - PxQzRy - PyQxRz - PzQyRx
Add these together for all facets and divide by 6.
Important! The P,Q,R for each facet must be arranged clockwise as seen from outside. (Or all counter-clockwise, as long as it's consistent for all facets.)
If the mesh has any quadrilaterals, just temporarily hallucinate a diagonal joining one pair of opposite corners. That makes it into two triangles.
Practical computationial improvement: Before doing math with P,Q and R, subtract the coordinates of some "center" point C. This can be the center of mass, a midpoint between the min/max x, y and z, or any convenient point inside or near the mesh. This helps minimize truncation errors for more accurate volumes.
From numerical point of view, what you are trying to achieve is quite simple and can be reduced to calculating few quadratures. Wikipedia will provide needed information about maths behind it.
If you are looking for out-of-the-box volume calculation, take a look at this entry.
As of inertia -- shape is not enough, as you also need distribution of mass.
Well, there isn't much information on the car being provided here - you should be able to break down the car into simpler shapes - the higher degree of approximation your require - the more simpler shapes you can break it into. (This could be difficult if the car is somehow dynamically generated and completely different every time ... but I don't see that situation making any sense).
This should help with finding the Inertial Tensor of various simpler shapes: http://www.gamedev.net/community/forums/topic.asp?topic_id=57001 , finding the volumes and the likes of things like spheres and cubes is pretty common knowledge so I won't bother linking that.
I think it was Archimedes who discovered that if you submerge the car in a volume of liquid, the displaced liquid will have the same volume as the car.
I'm not sure what this would help you in this case though. Having a liquid simulation running in the background and submerging the mesh into it sounds a bit over the top. Although, I think it does work, and therefore qualifies as a (bit useless nonetheless) answer. ;^)