X Y Z angles of a D20 (icosahedron) for gravity projection

21 ビュー (過去 30 日間)
NE
NE 2021 年 5 月 19 日
編集済み: NE 2021 年 5 月 21 日
Hi all,
EDIT#1: Added the .m script as an attachement
-------------------------- EDIT#2: Please read the comments --------------------------
Presentation (you can skip)
Thanks for your interest. Sorry for the title, it is a bit of a mouthful. Let me explain...
I have a large 3D printed D20 also named icosahedron. Basically, it has 20 faces. Please have a look at the attached picture :) .
I can attach a 3D angular sensor to any of the faces. The sensor would return me the 3D projection of the gravity like [0 0 -9.81] or [0 -4.905 -4.905].
What I would like to do
In Matlab, I would like to simulate this. To be more specific, given any of the 20 faces as a reference, I would like to get the 20 projections of the gravity (because of the 20 faces).
Let me explain this a bit more :)
Each time I "roll" the dice, I basically force one of the triangular faces to be "flat" (parallel to the XY plane). The reference face (to which my sensor is attached) is at a different angle. Therefore the gravity is not [0 0 -9.81] but a projection.
These projections are what I would like to calculate.
Therefore I think I expect to get a matrix like this:
projection#1 ---> [ [X Y Z];
projection#2 ---> [X Y Z];
...
projection#20 ---> [X Y Z] ]
What I can do
  1. I have managed to get a list of all the D20 vertices.
  2. With that, I can construct the 20 triangular faces of the icosahedron.
  3. And I can get the 3D normal vectors of each to each of the 20 faces.
Where I am stuck
But the part where I am stuck is calculating the 3D angles (can I name them roll/pitch/yaw?) given 2 normals to the planes:
  • the one which is flat
  • the one on which the sensor is attached
Do I need a quaternion? a rotation matrix? What would be the best way to calculate the 20 orientations?
I tried something like the following but it only retuns a single angle:
Angles_roll_pitch_yaw(cnt_face,:) = atan2(norm(...
cross(refrence_3D_vector,Normals_Vector(cnt_face,:))), ...
dot(refrence_3D_vector,Normals_Vector(cnt_face,:)));
Thank you very much for your time.
Sorry for the long post.
EDIT: I really can't understand if I need and what the function "vrrotvec" returns

採用された回答

James Tursa
James Tursa 2021 年 5 月 20 日
編集済み: James Tursa 2021 年 5 月 20 日
If you have the 3D normal vectors, then all you need to do is take the dot product between them and the "flat" face normal vector. This will give you the cos(angle) between them which you can use to multiply by the normal vectors to get your gravity projection. E.g.,
flat_normal = the 3D normal vector of the flat face
other_normal = the 3D normal vector of another arbitrary face
g = gravity magnitude
flat_gravity = g * flat_normal
other_gravity = g * dot(flat_normal,other_normal) * other_normal
Is this what you are trying to do?
Side Note: You may need to use -g instead of g to get things to match your sensors output. Strictly speaking accelerometers measure reaction force, not gravity, and reaction force is (sort of) in the opposite direction from gravity. The caveat is because if you are on the ground you would strictly need to account for rotation of the Earth to get a more accurate reaction force.
  7 件のコメント
James Tursa
James Tursa 2021 年 5 月 21 日
OK, I may have misunderstood your original question. I thought you were asking how much gravity (or reaction force) would be sensed along the normal direction to each face, and that is what I provided. I.e., if you had a single sensor mounted on that surface that only sensed acceleration along the normal direction to that surface.
But now with your talk of rotation matrices it sounds like you have a 3-axis accelerometer package attached to each face, so you need 3D mapping to each face package. Is that what you actually have? If so, then I don't see how just the normal vector directions gives you enough information to recover the rotation matrix. I.e., this sounds more like an alignment between two coordinate frames that you are trying to calculate. Is that it?
NE
NE 2021 年 5 月 21 日
quick note: I find the lack of "quote" formatting quite disturbing on this site, but I'll use "||"
Sorry, I should have explained it better. I have 10 IMUs, so I can cover 1/2 of the faces at once.
To find all the possible accelerations (1 per face), I have 2 choices, I think.
  • Choice1: I make an acquisition, then roll the dice only once, then make a second acquisition.
  • Choice2: Or I can just make an acquisition, then unmount the 10 IMUs, mount them to the 10 other faces without moving the D20, and then make my second acquisition.
||Is that what you actually have?
This is what I have. I should have spent more time on the hardware description (this is my first post).
||If so, then I don't see how just the normal vector directions gives you enough information to recover the rotation matrix.
From the formula from the gist, you apparently need only 2x 3D vectors v1 and v2 (the normals in my case), and it gives me logical results for the gravity projection, so I am quite pleased with that simple approach.
||I.e., this sounds more like an alignment between two coordinate frames that you are trying to calculate. Is that it?
I wasn't sure at the beginning, but with the gist, I am sure that the alignment is at least one (of the possibly other) ways to do it.
So to describe the process:
  1. Get the vertices coordinates
  2. Get the vertice face map (what are the 3 vertices per face)
  3. Calculate normal vector to each plane
  4. Create rotation matrix (3-by-3) from a reference face or any other plane, with their normal vectors (see the gist method)
  5. Use the rotation matrix to project the gravity vector (originally expressed in the reference face) on the new face.
  6. Enjoy the algorithm
Note: this might not be the most elegant and memory-efficient way because I need to store a 3-by-3-by-20 (or 19) matrix for all the rotation matrices but ¯\_(ツ)_/¯
Final question: should I put my final Matlab script in the attachment for the other to see or not?
Thank you so much for your time and your perseverance.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by