Skip to main content
KenFarley
21-Topaz II
December 17, 2013
Solved

Trigonometric functions give wrong values if supplied units

  • December 17, 2013
  • 3 replies
  • 7380 views

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.
Best answer by KenFarley

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.

3 replies

17-Peridot
December 17, 2013

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.

1-Visitor
December 17, 2013

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

17-Peridot
December 17, 2013

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

1-Visitor
December 17, 2013

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

KenFarley
KenFarley21-Topaz IIAuthor
21-Topaz II
December 27, 2013

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.

17-Peridot
December 27, 2013

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

1-Visitor
December 27, 2013

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.