PI in equations does not evaluate

PI in equations does not evaluate

niels_wittje
Contributor Contributor
3,315 Views
6 Replies
Message 1 of 7

PI in equations does not evaluate

niels_wittje
Contributor
Contributor

Hey all,

Inventor 2023, but also tested with 2021.

I have a problem with the buggy parameter PI. For the sake of an exercise, I try to draw a sin curve via an explicit equation curve shifted by PI/2 (so that the maximum is at the origin (yes, I could just take cos, I just do it for the exercise...!)). PI itself is accepted, as are different simple equations:

-PI + x

-PI + 2

-sin(PI)

-sin(PI+2)

However, as soon as I try to evaluate a calculation inside the sin() containing x AND pi, it fails:

-sin(PI+x)

-sin(PI*x)

and, my original one:

-sin(x+PI/2)

Is this a bug of the parser? How can I circumvent it?

Cheers, Niels

0 Likes
3,316 Views
6 Replies
Replies (6)
Message 2 of 7

SBix26
Consultant
Consultant

I suspect that the issue is with units.  What are the units of x?  Can you attach a sample file with an equation that fails?


Sam B

Inventor Pro 2024 | Windows 10 Home 22H2
autodesk-expert-elite-member-logo-1line-rgb-black.png

Message 3 of 7

niels_wittje
Contributor
Contributor

Hey,

attached a demo file (but it happens in all sketches). In the attached file, try to create an explicit equation curve with sin(x+PI/2) in sketch2. All units in mm.

Cheers, Niels

0 Likes
Message 4 of 7

Alexander_Chernikov
Mentor
Mentor

Hi, try

sin(x/1 mm+PI/2) 

Do you find the posts helpful? "LIKE" these posts! | Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням!
Have your question been answered successfully? Click "ACCEPT SOLUTION" button. | На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ"

Олександр Черніков / Alexander Chernikov

EESignature

Facebook | LinkedIn

.


Message 5 of 7

SBix26
Consultant
Consultant

Elaborating on what @Alexander_Chernikov  posted, the problem is with units.  If x is in millimeters, then how do we get from millimeters to an angular unit, which is what the sine function requires?  Sine of 5 mm is nonsense.  Sine of (5mm + PI/2) is also nonsense.  PI is unitless, and x is a length.  If you want to plot a sine curve, you will need to make x into an angle by dividing it by 1mm and multiplying it by 1 rad (or deg), then adding π/2 rad (or deg), take the sine of this angle, and then convert it back to a length by multiplying by 1mm.

 

So: y(x) = sin (x * 1 rad / 1 mm + PI rad / 2 ul) * 1 mm

 

SBix26_0-1684710281465.png

 

Inventor is units aware, so you can't just mix parameters.  x and y require length units and the sine function requires angular units, so you have to account for those.  If you don't include explicit angular units, Inventor assumes that any number entered in the sine function is in the default angular units of the file's settings, in this case degrees.  Since you're using π in the equation, I expect that you're working in radians, and therefore you will need to specify the units as I did above.

 

Hope that helps,


Sam B

Inventor Pro 2024 | Windows 10 Home 22H2
autodesk-expert-elite-member-logo-1line-rgb-black.png

Message 6 of 7

niels_wittje
Contributor
Contributor

Of course, thank you, I was expecting a different logic. I expected that pi is unitless and sin sanitizes everything to raw numbers (as I can also just do sin(x)), but the behaviour seems to become undefined there when there are mixed units inside. Because mm/rad/mm is also not a very clean operation programming wise… Can I just statically caste a unit onto a value without using the turnaround of multiple internal evaluations?

 

In the meantime, I will try around with this, thanks.

0 Likes
Message 7 of 7

johnsonshiue
Community Manager
Community Manager

Hi! I think this has something to do with the angular unit in the document. Go to Tools -> Doc Settings -> Modeling -> Units -> change the angular unit from deg to rad. Then it should work.

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes