Priscila,
I had hoped for an (early) answer from one of our scripting friends (it may still come).
For now, I believe the easiest way for you is to use something like this free online calculator, or its equivalent on your computer, at least for repeated/edited rotations,
https://www.calculator.net/scientific-calculator.html
Using that, you can get the exact angle quite easily and create the line at that angle with the Line Segment Tool in one go:
( https://helpx.adobe.com/illustrator/using/drawing-simple-lines-shapes.html )
1) In the calculator linked to, simply 1a) - 1d) press the keys shown in the image below, then 1e) select the angle by ClickDragging over it (or including at least the first 4 decimals);
2) Select the Line Segment Tool, then insert the length (30 mm), then insert the angle from 1), then press OK.
This way will give you the 30 mm line at the angle that makes the W value 27 mm; you can check it directly in the Document Info panel (click the three dots and choose Selected as well as Objects, I always have it showing this) and in the Transform panel.
And this way will correspond exactly to the script I had in mind; the web page even says: "This is an online javascript scientific calculator."

Click/RightClick to get closer