Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Equation Editor Syntax - Arc length = radius * angle

matthew_stacymatthew_stacy Member Posts: 487 PRO
I'm having trouble entering a formula into a sketched length dimension.  The intent is to set the length of the construction line segment equal the length of the adjacent arc, from variables #R and #theta (millimeters and degrees, respectively).  The correct result should be approximately 34.9mm (same as the arc length).

The formula should be the product of radius and swept angle (with the angle expressed in radians not degrees):
  • #R*#theta*PI/180,           (multiplying by π radians per 180 degrees to convert the angle from degrees to radians)
I've tried numerous variants, with and without the PI/180 conversion, peppered with rad and deg in every conceivable location.  Could someone please provide the correct syntax for this expression?  So far I keep running into the Enter a valid expression prompt.



Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,686
    edited September 2020
    You need to get the units to balance. The result of #R*#theta*PI/180 is length*angle so you need to get rid of the angle. Try #R*#theta*PI/(180*degree) 
    Senior Director, Technical Services, EMEAI
  • matthew_stacymatthew_stacy Member Posts: 487 PRO
    That was just the ticket.  Thank you @NeilCooke .
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,214
    Even easier is #R*#theta/radian
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • matthew_stacymatthew_stacy Member Posts: 487 PRO
    @ilya_baran, that works,  but please explain why.  What does /radian mean?

    From the perspective of dimensional analysis I've got the product of length (mm) and angle (degrees), but need to convert the angular unit to radians.  Is /radian code for a function call to "convert #theta from degrees to radians"?  That is not intuitive to me.
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,214
    The way to think about this is that #theta is an angle, rather than some number of degrees or radians (how we store it internally is beside the point).  In other words, #theta doesn't remember what units it was specified in, just what the actual angle was.  radian is a constant that is also an angle (that measures 1 radian, obviously).  So if you divide #theta/radian, you're dividing two angles and what you should get is a number.  That is the number of radians in #theta.

    Similarly, if you have a length and need to know how many millimeters it is, you would do #myLength / millimeter.  For example if #myLength is 3mm, you would get: #myLength / millimeter = 3 * millimeter / millimeter = 3.

    Hope this helps.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • matthew_stacymatthew_stacy Member Posts: 487 PRO
    ilya_baran, "how we store it internally is beside the point", but you have surely piqued my interest.  If I listened to the little man in the wizard of Oz saying, "don't worry about what's behind the curtain", I probably wouldn't have studied engineering all those years ago.  How does Onshape store an angular dimension internally?

    To verify your assertion, I created a new variable #num = #theta/rad

    Sure enough, if I set the value of #theta to 180degrees the value of #num updates to 3.142 which looks to be a perfectly good approximation of Pi as you promised.  Or if I set #num = #theta/deg the value updates to 180.

    This is fabulous, but what's under the hood?

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,214
    It's a lot more boring than I led you to believe :)  Internally, we just convert everything to radians, (or meters, for lengths) and do all computations in those "base" units.  But ideally, we could change the base units to hexacontades and smoots tomorrow and nothing would break (we're of course not going to do that).
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • matthew_stacymatthew_stacy Member Posts: 487 PRO
    Thanks @ilya_baran :smiley:
Sign In or Register to comment.