How to color particles based on their orientation?

Mrage
Mrage Altair Community Member
edited October 2023 in Community Q&A

Hey,

I am trying to color my particles (2-Sphere-Clumps) according to their orientation, to analyze how they arrange horrizontely. However, I cannot find this option within th analyst coloring section. Can I still do this somehow within the analyst section or do I need to use Python API?

 

Thanks and best regards

Leandro

ScS.JPG 64.1K
Tagged:

Answers

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited September 2023

    Hi Leandro,


    The EDEM Analyst doesn't allow you to colour particles by orientation unfortunately, you can export the orientation matrix (3x3 orthogonal matrix) and this data is also available via EDEMpy but not directly in the analyst.


    It's worth noting that the orientation matrix is the matrix required to rotate the particle back to the position shown in the Creator, so this is always relative to the particle defined in the Creator.

    Regards

    Stephen

  • Mrage
    Mrage Altair Community Member
    edited October 2023

    Hi Stephen,

    thank you very much, that helps me already! Which component of the orientation (XX, YY, ...) do I have to export to determine the angle according to the attached figure "Par_Orientation". Could you please explain this again? Also attached are screenshots of the creator view and the analyst view. I want to consider only the 2-dimensional case. 

    Thank you very much and kind regards
    Leandro

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited October 2023
    Mrage said:

    Hi Stephen,

    thank you very much, that helps me already! Which component of the orientation (XX, YY, ...) do I have to export to determine the angle according to the attached figure "Par_Orientation". Could you please explain this again? Also attached are screenshots of the creator view and the analyst view. I want to consider only the 2-dimensional case. 

    Thank you very much and kind regards
    Leandro

    Hi Leandro,

     

    This is a useful link for visualising the matrix:

    http://www.euclideanspace.com/maths/algebra/matrix/transforms/examples/index.htm

    also

    https://en.wikipedia.org/wiki/Rotation_matrix

    EDEM is always going to have a 3D matrix but if working in 2D you can just take for example the YY orientation value which is cos(Theta).


    Regards

    Stephen

     

  • Mrage
    Mrage Altair Community Member
    edited October 2023

    Thanks Stephen,

    just to make sure. If i get the following 3x3 orthogonal matrix,

    XX YX ZX
    XY YY ZY
    XZ YZ ZZ

    how can i calculate the angle of the rotation around the y-axis (Theta_Y). I found the following solution:

    Theta_Y = arctan2(XZ, (XX^2+XZ^2))

    This works for simple examples I have been going throgh. But would this be the correct approch?

    Thanks a lot!

    Leandro

     

  • Mrage
    Mrage Altair Community Member
    edited October 2023

    In case anybody is intrested.: I solved my case using scipy libary. Basically what i was looking for are "euler angles"! Here is an example:

    from scipy.spatial.transform import Rotation as R 
    import numpy as np

    r = R.from_quat([0, 0, np.sin(np.pi/4), np.cos(np.pi/4)])
    r.as_matrix() array([[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00], [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00], [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]])  
    r.as_euler('zyx', degrees=True) array([90.,  0.,  0.])