Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape, CAD, maker project and design.

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.

Ray Tracer half transparent mirror

Hi, I'm using the Ray Tracer in Onshape for optical simulation. In my situation I need a half transparent mirror with transmission and reflection. In the Ray Tracer settings I can only set the reflection or the transmission. I need booth. It is possible to set both values? Or is there an other solution?
Thanks for all answares.

Best Answer

Answers

  • ilya_baranilya_baran Onshape Employees, Developers Posts: 781
    This is not currently possible with that feature -- its source code would have to be modified to support this.
    Ilya Baran \ Director of FeatureScript \ Onshape Inc
  • norbert_walter937norbert_walter937 Member Posts: 3
    Thanks for your answare. The Ray Tracer is very interesting for me. Specially in combination with mecanical designs. In this case I can check the system functions over the completely design. I d'ont need a full function Ray Tracer. Easy functionality is enough. For a better integration is following necaessary:
    • transmission and reflection at same time
    • easy light source generator with multible beam array
    • roughness as property for objekts (for different reflection directions)
    • wave length as property (refraction calculation)
    • easy lens generator (nice to have)
    Are this topics possible in a future version?

    I think this features are necessary and usefully also for education.
  • ilya_baranilya_baran Onshape Employees, Developers Posts: 781
    The ray tracer is a sample custom feature developed by @maximilian_schommer while he was a summer intern with us -- it is not a part of Onshape's core functionality and so we do not have resources we can allocate to its development.  If you are comfortable with code, you can add the functionality you describe yourself or you may be able to interest someone in the community (or may be an Onshaper on their own time) to build it.
    Ilya Baran \ Director of FeatureScript \ Onshape Inc
  • norbert_walter937norbert_walter937 Member Posts: 3
    Thanks for yours answares.
    @ilya_baran : I understand the situation. At the moment I have no experiences with code developping in Onshape. I'll try it soon.
    @philip_thomas : This is exactly what I need. The solution is a usefully nice trick. Thanks :-)
  • maximilian_schommermaximilian_schommer Member Posts: 16 EDU
    Hi @norbert_walter937

    The ray tracer originally did give both the reflected and refracted ray, and it would be pretty simple to make a check box so that functionality is added to it again.

    I'll see if I can get to it soon! Thanks for the suggestion!

    Maximilian Schommer
  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 988
    Perhaps to avoid a lot of unnecessary rays it would be more helpful to add the 'both' as a characteristic of the body and not of the ray! :)
    Philip Thomas - Onshape
  • maximilian_schommermaximilian_schommer Member Posts: 16 EDU
    Thanks @philip_thomas and @norbert_walter937 for the suggestions! 

    I was able to implement the semi-silvered mirror functionality, which appears in the setup as being able to check a box for reflection and refraction for each part selected.  The other suggestions about roughness, wavelength, etc. are great ideas, and I'll hopefully get around to them soon! Release 4 is where the new functionality lives.

    Maximilian Schommer


  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 988
    It occurred to me afterwards that asking for this meant you had to deal with recursion as every bounce produced two more rays to follow!
    Nicely done! :)
    Philip Thomas - Onshape
  • ivan_skachkoivan_skachko Member Posts: 4
    Ray Tracer is indeed a very useful and efficient custom feature, however I encountered a bug in it. As the attached image shows, RT works well tracing a beam in the FRONT plane (the same plane where I sketched lens' profile to be revolved), but fails for the beam with identical parameters in the TOP plane. The problem seems to  stem from feature script code ( var rayEndPoint = getRayIntersection(context, id, rayToTrace); ) not being able to compute the intersection of the ray with the back surface of the lens for some reason. Looking at the script for this feature I am generally curious why it takes so much code to find an intersection between a line and a surface of a body.
    I understand that Ray Tracer will not be developed further by Onshape, but I wanted to bring the issue to the attention of the users.
  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 988
    Philip Thomas - Onshape
  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 988
    @ivan_skachko - Max (the author of this custom feature) may chose to shed light on the other part of your statement, but my understanding based on discussions before Max started working on this, was that the following is true. There is no call in Parasolid to determine the intersection of a line and a body/face. For that reason, Max's code generates an artificial entity (i think its a surface), to be able to get that. I hope that puts your mind at rest :)
     
    Philip Thomas - Onshape
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 613 ✭✭✭✭
     There is no call in Parasolid to determine the intersection of a line and a body/face.
    but what about evDistance, it can use a Line for one of the sides of measurement as stated in documentation. so you can detect if it intersects the face and evaluate normal in intersection point. or i'm missing something?
  • ilya_baranilya_baran Onshape Employees, Developers Posts: 781
    @philip_thomas Parasolid definitely has such calls.  They were just not exposed to FS as is.  The problem with evDistance is that it returns some intersection, not just the closest one, which is what is needed here.
    Ilya Baran \ Director of FeatureScript \ Onshape Inc
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 873
    @konstantin_shiriazdanov

    There are issues with the evDistance approach.  If you use it to intersect a Line and a cylindrical face which it passes through twice, it will be very hard to detect the situation, and hard to gather the other intersections using evDistance alone.  Also looping though every face of the selected bodies and running an evDistance could get very expensive.

    Parasolid does support arbitrary intersections between curves and faces, but this is not currently exposed to FeatureScript, which is where the extrude 'up_to_next' approach came from.  It's an easy built-in way to find the next intersection from a location to a set of bodies.
    Jake Rosenfeld - Modeling Team
  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 988
    I love it when all the smart people turn up to the same party :)
    Philip Thomas - Onshape
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 613 ✭✭✭✭
    Also looping though every face of the selected bodies and running an evDistance could get very expensive.
    my Fold FS for unfolding arbitary extruded surface evaluates evDistance every 0.5 mm along the bounding edges of the face. that what should be called "very expensive" :)
    the ambiguity of evDistace in the case of several possible intersections seems to be the main problem
  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 988
    @konstantin_shiriazdanov - wait, did you write a flattener????
    I am very excited (i want one :)) - is it public?

    Many thanks - Philip
    Philip Thomas - Onshape
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 613 ✭✭✭✭
    hi @philip_thomas
    they are all in the same document, because they share a little library of functions for curve transforms, the one you want is Fold FS with fold/unfold options. It works with rather common extracted surfaces but makes some geometry distrosions (about 0.5 % of length).
    https://cad.onshape.com/documents/0bb13c1b6ed6d4a6dd75cf99/w/b4493d47a45c27ce485c84b9/e/1299ae499a697e3b28bca1e4

  • maximilian_schommermaximilian_schommer Member Posts: 16 EDU
    Ray Tracer is indeed a very useful and efficient custom feature, however I encountered a bug in it. As the attached image shows, RT works well tracing a beam in the FRONT plane (the same plane where I sketched lens' profile to be revolved), but fails for the beam with identical parameters in the TOP plane. The problem seems to  stem from feature script code ( var rayEndPoint = getRayIntersection(context, id, rayToTrace); ) not being able to compute the intersection of the ray with the back surface of the lens for some reason. Looking at the script for this feature I am generally curious why it takes so much code to find an intersection between a line and a surface of a body.
    I understand that Ray Tracer will not be developed further by Onshape, but I wanted to bring the issue to the attention of the users.
    @ivan_skachko

    Thanks for the bug find! I'll take a look at it when I have time! The reason that it takes so much code to find the intersection of a ray and a surface is because there is no function in onshape that lets you calculate that uniquely. I'm using a workaround, where to "project" the ray, I'm extruding a very thin surface, and finding where the surface intersects another body. It's a bit strange, but it's the only way I know of to trace rays reliably. There have been strange bugs I've had to deal with such as rays intersecting surfaces at locations like the center point of a revolve, where a normal isn't properly defined, and I'll take a look at this bug and see what the issue is. Thanks again for pointing it out!

    Max
  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 988
    @konstantin_shiriazdanov - THANK YOU - i am thrilled! :)


    Philip Thomas - Onshape
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 613 ✭✭✭✭
    @philip_thomas
    i should specifically mention - this fs was made to make correct flats from faces of surfaces that might be obtained by extraction operation. and the face should be situated to the one side of the "profile edge". in your case i see that you apply it to the lofted face. if the resulting region mathches original face by area and length of bounding edges I would be surprised a lot  :o
  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 988
    @konstantin_shiriazdanov - hmm :)

    So the difference in surface area is 2.8% in this case.

    My apologies for not understanding what you mean by - "the face should be situated to the one side of the "profile edge"". 
    Would you please explain?
    Is there anything else i can do to improve accuracy?
    I would like 1% or better.

    Many thanks - Philip
    Philip Thomas - Onshape
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 613 ✭✭✭✭
     "the face should be situated to the one side of the "profile edge"
    I meant that when you select face or edge to transform and then generatrix profile edge the generatrix profile shouldn't cross any edge you need to flatten (but it may be one of the bounding edges) because internally it doesn't differ the direction since evDistance return unsigned value.

    >Is there anything else i can do to improve accuracy?
    sorry, can't think about something suitable right now, it uses numerical algorhytms of evDistance and of finding length parameter and seem like most numeric mistake is in x coordinate which is evaluated by my numeric function. if i find how to improove it i'll tell you.
  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 988
    @konstantin_shiriazdanov - Please accept my apologies - your English is 100 times better than my Russian (Ukrainian?), but i have no idea what you just said! :)

    I think you said that when flattened, the profile edge should not cross the surface being flattened.
    My apologies again if this is way off.

    As it stands right now, this custom feature is a huge help and I am very grateful!

    Thank you for all your support in the forums :)
    Philip Thomas - Onshape
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 613 ✭✭✭✭
    @philip_thomas
    sorry, that i'm training my english on you)
    I think you said that when flattened, the profile edge should not cross the surface being flattened.
    that is it! an example of what happens when selected profile edge cross flattening entities

  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 988
    @konstantin_shiriazdanov - got it - thank you! :)
    Philip Thomas - Onshape
Sign In or Register to comment.