cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Trigonometric functions give wrong values if supplied units

KenFarley
21-Topaz I

Trigonometric functions give wrong values if supplied units

I have noticed a rather annoying problem with using Creo parameters with trigonometric functions in relations.

The observed behavior is as follows:

 

(1) Define your parameter with units, for example I define "angle" with a value of 15.0, Unit Quantity of "Angle" and Units of "deg", the result of "tan ( angle )" yields 0.04569. A wrong answer.

(2) Define your parameter with no value for either Unit Quantity or Units, and tan ( angle ) yields 0.267949, which is correct for 15 degrees.

(3) Do a "dumb" evaluation of "tan ( 15.0 )" and you again get 0.267949.

(4) Define your parameter with a value of 15.0, Unit Quantity of "Angle", and Units of "rad", and tan ( angle ) yields 0.267949.

 

So it appears that if you exercise "proper" practice and define your units correctly, you are delivered erroneous results. Put in the wrong units and you get the right answer.

 

Luckily, the error is so different from the correct answer that it is easy to see it's wrong. In this case.

 

Has anyone else observed this behavior?

 

For interest's sake, I'm running Creo 2.0, build M070.


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
1 ACCEPTED SOLUTION

Accepted Solutions

The bug has apparently been addressed as detailed in the following

"In regards to call number 11768196, SPR 2205098 has been returned by development as "Fix Submitted". As a reminder, this SPR has a description of "Customer reports for incorrect results when using trigonometric functions in relations in Creo Parametric 2.0.". This issue has been resolved in Creo Parametric 2.0 Datecode M110, which can be downloaded at http://www.ptc.com/cgi/cs/apps/SftUpd/SftUpdProd.pl when it becomes available."

So, mid May or so.

View solution in original post

13 REPLIES 13

I have had nothing but trouble trying to use parameters from various values only to find unit errors. Internally it seems the receiving parameter doesn't evaluate the output from the function. This seems like an oversight in coding but it is pretty much expected by the user. Of course, you can know this and account for it by converting the value to the appropriate value using some additional math.

Quite often I want to use angular... and it fails due to unit of measure problems. You really have to work at it to convert these. Almost we need a generic(<parameter>) function so the unit of measure is stripped. Maybe there is one and I just haven't found it yet. I just know it fails at very inopportune times.

Both answers are "correct". In one case Creo evaluated the expression using radians, the other is in degrees.

In the case where you've specified your units, Creo has converted them to radians which is the default in the IPS system of units (I can only assume you are using IPS since that is Creo's default). I believe this is occuring because you have "mixed units" in your relation because the trig functions use radians and you've specified the unit of angles.

I did a quick test by taking the tan of angle specified as degrees and then converted it back to the angle using atan. As long as the units are consistent, I didn't see any problem. 15 degrees became .004569 but then became 15 degrees again when my parameter I read the relation back into had the units of degrees. It works correctly, you just have to be extremely careful with your system of units and how they are handled in relation functions.

You can tell Creo to ignore units in relations and it will behave as if you didn't specify parameter units to begin with. Then your "wrong" answer will never show up...just make sure you aren't relying on the ability of relations to convert units.

Click the button below or set the corresponding config.pro option:

relations_units_sensitive

unit_sensitivity.jpg

Thanks Eric. That looks like a global toggle. That is scary!

I believe the config.pro is global but the button toggle is specific to the object you are viewing.

Thanks... I will do some testing to confirm.

I should clarify my post above.

To get to the .004569 value, it is basically converting 15 degrees to radians twice!

It sees that 15 is in degrees and converts it to radians then it looks like the tan function takes that value and does the radian conversion again before doing tan(). As long as you repeat the process backwards you will get back your 15 degrees but the value of tan(15degrees) is useless. Maybe you should bring it up to PTC.

I've submitted this as a bug report and been in contact with the people associated with such.

I did some experimenting with the problem, and reported the following results:

(1) Define your parameter with units, for example I define "angle" with a value of 15.0, Unit Quantity of "Angle" and Units of "deg", the result of "tan ( angle )" yields 0.04569. A wrong answer.

(2) Define your parameter with no value for either Unit Quantity or Units, and tan ( angle ) yields 0.267949, which is correct for 15 degrees.

(3) Do a "dumb" evaluation of "tan ( 15.0 )" and you again get 0.267949.

(4) Define your parameter with a value of 15.0, Unit Quantity of "Angle", and Units of "rad", and tan ( angle ) yields 0.267949.

So it appears that if you exercise "proper" practice and define your units correctly, you are delivered erroneous results. Put in the wrong units and you get the right answer.

The "solution" of turning off unit sensitivity is not viable, since I am using that functionality to do a number of other calculations.

Kenneth, have you reported this in a support case yet?

I did a little more digging as well with similar results. The help files say that "all trig functions use degrees", which worries me that they were never intended to use parameter units to begin with. I did the below with the following results:

trig_on_degrees=tan(angle_degrees) predefined parameter with units. BAD

trig_on_radians=tan(angle_radians) predefined parameter with units. BAD

trig_on_none=tan(angle_none) predefined parameter no units. GOOD

trig_on_feature=tan(d13) feature with undefined units of degrees. GOOD

deg_rad=15[rad] new parameter, incorrect units defined on the fly.

trig_on_degtorad=tan(deg_rad) GOOD

rad_deg=15[deg] new parameter, incorrect units defined on the fly.

trig_onradtodeg=tan(rad_deg) BAD

Finally, I tried switching to several different sets of system units and nothing changed. I was hoping that perhaps the problem was that the parameter units are different than the system units so they are automatically converted. So switching the system of units to something compatible with the units in the parameters would keep it from being converted. Either there are no system of units with degrees or else something else is going on.

So, until they fix their software, it looks like for trig functions you either have to specify no units or incorrectly designate them as radians (15rad instead of 15deg). That's really messed up.

I'm on Creo 2.0 M070 as well.

Hi Antonius,

Yeah, like it says, I submitted a support/bug case on this. Got a call from someone, and it's currently being investigated. Hopefully a bug fix in the next build.

Thanks... looking forward to PTC's reply to this. This is pretty serious.

The bug has apparently been addressed as detailed in the following

"In regards to call number 11768196, SPR 2205098 has been returned by development as "Fix Submitted". As a reminder, this SPR has a description of "Customer reports for incorrect results when using trigonometric functions in relations in Creo Parametric 2.0.". This issue has been resolved in Creo Parametric 2.0 Datecode M110, which can be downloaded at http://www.ptc.com/cgi/cs/apps/SftUpd/SftUpdProd.pl when it becomes available."

So, mid May or so.

Thanks for the update, Kenneth. I am glad they took your observations seriously.

I wonder if other analysis calculation were affected and returning wrong results.

Top Tags