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

Trigonometric functions give wrong values if supplied units

SOLVED
Highlighted
Tanzanite

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Trigonometric functions give wrong values if supplied units

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
Highlighted

Re: Trigonometric functions give wrong values if supplied units

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.

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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.

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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.

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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.

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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.

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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

Highlighted

Re: Trigonometric functions give wrong values if supplied units

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.

Announcements