0

So I have the point "D", the yaw rotation "Y" of the complete object and the EulerAngle of the arm sitting on the shoulder. Now I want to find out the vector "V" and at the end the point "P". I also know the length of the arm. It's around 0.7. I have spend lots of hours with a friend of mine trying and changing values. He is much better then me with rotation matrices etc but he gave up. So I searched in the web but did not find a suiting answer. Can someone help me/us?

View Picture

Alex
  • 5,565
  • 6
  • 36
  • 57
Jalau
  • 303
  • 1
  • 2
  • 11

1 Answers1

0

Start with the vector V in your coordinate system (I presume (0, -1, 0)).

Now rotate it by the rotation matrix for rotating around axis X by the angle at which the arm is lifted (assuming angle=0 means the arm points down).

Finally, rotate the vector around the Y axis with the proper angle coming from the base rotation of your stick figure.

This gives you the vector V in world coordinates. Add it to the point D if you want to get P.

cfh
  • 4,576
  • 1
  • 24
  • 34
  • That seems to work but what about the rotation around the z and y axis? At the moment the rotation around the z axis is very low but it's there. So i just rotate it around the z axis with the z rotation of the eulerangle? The y rotation should matter. But I'm curious would I use rotateAroundY(baseRotation + yEulerAngle)? – Jalau May 25 '15 at 18:34
  • EDIT: As soon as I change the x eulerangle of the arm to like 90 for example the location does not match the hand of the arm anymore. The output point is somewhere behind the object. I tested it with the x angle 0 and it does indeed mean that the arm points down. And at the angle of 0 it perfectly works but as soon as I change it it does somehow get more and more inaccurate. – Jalau May 25 '15 at 18:42
  • Code: `public Vector3f angleToVector(EulerAngle angle, double yaw) { Vector3f vec = new Vector3f(0, -1, 0); Matrix3x3f m = Matrix3x3f.IDENTITY.deepClone(); m.multiply(Matrix3x3f.getRotationMatrixX(angle.getX())); m.multiply(Matrix3x3f.getRotationMatrixY(Math.toRadians(yaw))); //m.multiply(Matrix3x3f.getRotationMatrixZ(angle.getZ())); return m.multiply(vec); } ` – Jalau May 25 '15 at 18:46
  • @Jalau: I don't know what framework you're using, but you may need to reverse the order in which you multiply these matrices. – cfh May 25 '15 at 21:12
  • I'm using a custom made one by my friend: http://pastebin.com/mrGDYEmJ The Vector3f constructor looks as follows: ' public Vector3f(float x, float y, float z) { super(); this.x = x; this.y = y; this.z = z; } ' – Jalau May 26 '15 at 14:57
  • @Jalau: Try multiplying the matrices in reverse order. – cfh May 26 '15 at 14:58
  • So first around the Z Axis then Y Axis and then around the x axis? – Jalau May 26 '15 at 15:00
  • As of now it works great! Thanks! I will contact you if I notice something off. – Jalau May 26 '15 at 15:26
  • But I neded to invert the yaw. EDIT: If I change the Z rotation it still is somehow very off somewhere other. And how do I add the Y rotation if I already use the yaw and rotate that around the y axis but also have the y rotation of the arm. How can I add that? Thanks for your help. – Jalau May 26 '15 at 15:33
  • 1
    @Jalau Instead of "hiding" code in comments, please place them in your question so that those who would like to help you can have an easier time looking at them. – Unheilig May 28 '15 at 02:54