Jump to content

Element's rotation from XYZ axes?


2kristof2

Recommended Posts

Posted

Hello,

I would like to know how to get rotation of an element (rx,ry,rz) if I have its x,y,z axes and their positions (P1, P2, P3 and element's position are given like in the picture below). Some maths are needed but unfortunately calculating angles is not my strong side. Thanks in advance.

Ez0yurP.png

 

  • Moderators
Posted

What has position in your case to do with rotation? If you have 2 positions, then it would be something else.

 

getElementRotation

 

Posted

The element is attached and getElementRotation won't return actual rotation but rotation before attaching. And yes I know all those functions related to attachments but there are needed even more complicated maths to rotate an element by setting its offsets.

  • Moderators
Posted

Yea, thought you missed something in your explanation.

You can try to check with getElementMatrix. But I can't help you getting rotations from rotation offsets of matrices, too much for me.

 

 

 

Posted
3 hours ago, IIYAMA said:

I tried with getElementMatrix but it seems like it doesn't return correct rotations, at least not everytime (there is an option to get rotation from matrix using OOP, this is what I used)

 

 

 

Posted (edited)

element1
element2 -> attached to element1

When you attach these two, get the rotation of element1, and element2. Save them in a table (rotations).
Then, when you are trying to get the element2's actual rotation, just get the rotation of element1, and have 3 new variables:
differenceX = rotations['element1'][1] - getElementRotation(element1)[1] -- make differenceY and differenceZ like this
Then, you can get the element2's rotation, with rotations['element2'][1] + differenceX, or if it's not working, use - of + instead.


I hope this can be working! ;)

Edited by MakroBox

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...