Slightly Different Angle Between Vectors Constraint - constraints

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.

Related

distm in R leads to crash

So I have a pretty simple question regarding the size of my data. I am trying to calculate the distance between all sets points (WGS84) in a dataset (56000).
https://www.rdocumentation.org/packages/geosphere/versions/1.5-10/topics/distm
According to the documentation: distm(x,y,fun="") if missing, y is the same as x
mydist<-distm(coordinates(mySpatialObject), fun="distHaversine")
This led me to an Error that y was missing. So I figured I could easily work around this.
distm(coordinates(WeedClim.plot),coordinates(WeedClim.plot), fun="distHaversine")
This leads to not just R:Studio, but my entire computer freezing. I had to to a hard reset twice now and do not want to go through this again, because this is my dissertation and I am afraid of breaking something else in the project XD.
Any ideas/solutions? Is there a better function that gives me a distance matrix from a set of coordinates?
THANKS!

How to decompose a unknown transformation matrix?

I'm working in the revitalization of an old 3d game (built using Direct3D) and I'm struggling with the game objects animations.
The game has its objects animations stored in binary files that contains transformation matrices for each bone of its meshes at each frame of the animation (in the form of an array of D3DMATRIX).
I've tried using the D3DXMatrixDecompose function to get the position, rotation and scale but it seems that something is wrong with the animation. Some animations almost matches the originals, but there are some strange rotations in the middle of the animations (the scale vector goes from negative to positive values and that causes the whole bone to rotate in an strange way - it is definitely wrong) and for other animations the whole thing is wrong.
I read somewhere that the function D3DXMatrixDecompose assumes the matrix was composed as a SRT matrix and apparently the order in which each component was combined in the matrix matters. So, as the animations are clearly wrong I'm assuming maybe the matrices were not composed in the SRT order and the output of D3DXMatrixDecompose is wrong.
I didn't find much material to read about this without going very deep on math. As I don't have a strong background on math, hopefully someone can point me in the right direction.
So, how can I decompose position, rotation and scale of an unknown transformation matrix? I'm not asking for a unique algorithm that can do that, I'm asking what I can do in this scenario to find the original (or equivalents) values for the position, rotation and scale of each matrix.
Thanks in advance!

Suggested package/function to compute the vertices of a 3-simplex (tetrahedron)

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.

quality analysis of fitted pyramid

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.

cross ratio - what to do with the received factor?

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

Resources