0

I'm not sure if something like this has been asked but I've spent days trying to figure this out to no avail.

I've been working on a project that has a straight tube and a sleeve placed some length down the tube, this part of the problem isn't causing any issues but the orientation of the placed sleeve is. When the sleeve is placed it is given a location that intersects another object giving it all the information it needs to be placed, but I need that sleeve to orient itself with the tube, pretty much just along the roll axis, but I would like to hammer out how yaw and pitch would be done similarly.

The tube has transform data connected to it. It has an origin for the center point of the tube, and 3 xyz points standing for each basis axis. in example for one of the tubes tested:

origin:{(119.814557964, -37.330669765, 8.400185257)},
BasisX: {(1.000000000, 0.000000000, 0.000000000)},
BasisY: {(0.000000000, 0.939692621, 0.342020143)},
BasisZ: {(0.000000000, -0.342020143, 0.939692621)}.

In some of the solution parts I've come across I found some ways this information is used. And I've had some success with this way of doing it:

(note: I realize this code has a lot of pointless variable use, I didn't want to adjust it and confuse myself more)
upDownAxis = givenSleeveObject.passedOnTransform.BasisZ;
leftRightAxis = givenSleeveObject.passedOnTransform.BasisX;
tempOfVector = givenSleeveObject.passedOnTransform.OfVector(upDownAxis);//this ofvector is applying the transform to the vector
rotationAngle = upDownAxis.AngleOnPlaneTo(tempOfVector, leftRightAxis);

This was able to give me the angle rotation of this particular tube which was 20 degrees. The problem is that this doesn't really work along the y axis the same, and completely wrong along the z axis. Likely due to after rotating to z axis the axis for each direction changes to one of the others at that angle. Also if it is of any help, the direction of the tube basically follows the basisX. If z is the only one with a 1, it is heading upward.

So now my issue is, how can I find the roll of this tube no matter it's orientation? Also rotation direction might matter in the long run. Since this object's transforms are all connected to itself, there must be a way to know how much of a roll has been done to it even at an extreme of 45 in every axis, right?

  • Does this answer your question? [Is there a way to calculate 3D rotation on X and Y axis from a 4x4 matrix](https://stackoverflow.com/questions/56900173/is-there-a-way-to-calculate-3d-rotation-on-x-and-y-axis-from-a-4x4-matrix) – Spektre Oct 05 '22 at 06:26
  • I'm not sure how much this answers it. I've looked it over a few times and some of the associated things, and they have given me some more insight, but I can't seem to really make heads or tails of it. I've always hated working with matrixes. Now there's all this and that about matrixes, vectors, and points. I know them more by name than concept, so I can't seem to grasp it. Suppose I really need to sit down and do a bunch of studying sometime... I'll have to double back and mark it once I have time and figure it out – Chris K Oct 07 '22 at 07:04
  • the `origin,BasisX,BasisY,BasisZ` are the 4 columns of 4x4 transform matrix you just add the last row `0,0,0,1` ... so first you create matrix using known euler angles like `10,20,30` [deg] and pass the resulting matrix to the `matrix2euler_init` to get the configuration your system uses (just once on app init) and then simply for any matrix (like your input) call `matrix2euler` which returns the euler angles you want – Spektre Oct 07 '22 at 08:20

0 Answers0