get front face of polygon based on rotation

sacha_sk

New member
Joined
Sep 26, 2021
Messages
2
CleanShot 2021-09-26 at 15.46.18.png
I've got a cylinder with 9 radial segments, resulting in 9 faces, representing f.
Each face shows a number, representing n.

I can rotate this cylinder on it's X-axis to show a different face. To get this rotation I use the following formula:
[math]r = ((360/f*n) - (360/f/2)) / 180*\pi[/math]
So when e.g. f = 9 and n = 1 we get r = 0.35

Now say f = 9 and r = 1.75, how would be get the value of n?

Any help is appreciated, thanks
 
I solved this in the following way:

We can get the rotation in degrees from r
[math]rDeg = r * 180/\pi[/math]
we can then put this back in range of 0-360
[math]rDeg360 = rDeg - (360 * floor(rDeg / 360))[/math]
now we know rDeg360 we can calculate n=? like this
[math]n = (rDeg360 + (360 / f / 2)) / 2 / (360 / f / 2)[/math]

It is very likely that this could be solved in a cleaner way or at least, written down in a cleaner way. Feel free to suggest other solutions, I'm here to learn.
 
Work is much easier if you simplify first, rather than writing everything in the most complicated way you can think of. (For example, why write 360/f/2 rather than 180/f?)

The formula simplifies to [math]r=\frac{360}{f}\left(n-\frac{1}{2}\right)\frac{\pi}{180} = \frac{(2n-1)\pi}{f}[/math].

To solve this for n, just multiply by f, divide by pi, add 1, and divide by 2. Then, for f = 9 and r = 1.75, I get n = 3.
 
Top