Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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 - Refraction in adjoining parts?
John_Christiansen
Member Posts: 5 ✭
I am attempting to model refraction at the interface of two differing materials using the Ray Tracer feature script. I am finding that the feature script does not account for adjoining materials. Rather, the entrance and exit of the traced ray from any part acts as if the interface were between the part and air (the "medium" as defined in the Ray Tracer setup).
Reference document link: https://cad.onshape.com/documents/480c079de04a57b2b4e460da/w/97683ca07ef3a54828fe65ac/e/d93e36d310047ae8b78930b7?configuration=List_4kFJp9OvaVhgL5=Default;List_Azxmm8NwScCLJA=No_Gap&renderMode=0&uiState=64fb832334c4d04337f0f976
The document link above is set up to demonstrate this issue. Two parts are modeled with different refractive indices. A ray originates near the bottom of Part 1, aimed upwards towards Part 2. At the interface of Part 1 and Part 2, the desired behavior is that the refraction angle would be calculated as a function of the indices of refraction of Part 1 and Part 2. However, that appears to not be the case.
Construction lines are created in the "Ray definition" sketch that show the incidence angle (in Part 1) and the expected refraction angle (in Part 2).
A configuration drop-down is set up to adjust the gap size between the two parts. Below are listed the three conditions of that configuration table, and the resulting output.
This is my first exposure to FeatureScript, so while I read through the code, I'm not picking up all the details to solve the problem on my own just yet. Is anyone out there familiar with this script? Or perhaps someone might be willing to dig into the issue?
I'm tagging @maximilian_schommer , though I'm not sure if he is still involved or active with OnShape development.
Reference document link: https://cad.onshape.com/documents/480c079de04a57b2b4e460da/w/97683ca07ef3a54828fe65ac/e/d93e36d310047ae8b78930b7?configuration=List_4kFJp9OvaVhgL5=Default;List_Azxmm8NwScCLJA=No_Gap&renderMode=0&uiState=64fb832334c4d04337f0f976
The document link above is set up to demonstrate this issue. Two parts are modeled with different refractive indices. A ray originates near the bottom of Part 1, aimed upwards towards Part 2. At the interface of Part 1 and Part 2, the desired behavior is that the refraction angle would be calculated as a function of the indices of refraction of Part 1 and Part 2. However, that appears to not be the case.
Construction lines are created in the "Ray definition" sketch that show the incidence angle (in Part 1) and the expected refraction angle (in Part 2).
A configuration drop-down is set up to adjust the gap size between the two parts. Below are listed the three conditions of that configuration table, and the resulting output.
- Gap: In this condition, a small gap is created between Parts 1 and 2. The ray refracts across the [Part 1]:[Air] interface, then again at the [Air]:[Part 2] interface. The final ray angle inside of part 2 is at the correct angle, but is offset from the expected ray position as a function of the size of the gap between the two parts.
- No Gap: In this condition, there is no gap between Parts 1 and 2. Something goes really wrong here. The ray is reflected internally, rather than refracting into Part 2. This is the issue/error.
- Negative Gap (Overlap): In this condition, Part 2 is modeled to overlap Part 1. Similar to Condition #1 in this list, there are again two refraction steps resulting in a ray paralell to the expected ray angle, but offset from the expected ray position.
This is my first exposure to FeatureScript, so while I read through the code, I'm not picking up all the details to solve the problem on my own just yet. Is anyone out there familiar with this script? Or perhaps someone might be willing to dig into the issue?
I'm tagging @maximilian_schommer , though I'm not sure if he is still involved or active with OnShape development.
0
Comments
Hopefully @maximilian_schommer chimes in though, since I'd rather just add onto his feature rather than re-invent it.
Regarding the surface roughness feature: I would have use for that feature. I am working on a design to evenly illuminate an object at close range. LED's being concentrated light sources, this requires a lot of physical prototyping. Some method of modeling scatter could help with that.
My dream feature right now would be internal scattering (reflections) in a not-entirely-clear material. That could get complicated quickly, though I can imagine that with clever implementation it might just be a reimplementation of the surface reflection applied with some proportional random frequency inside the material.
In the meantime, I am trying (well, a co-worker is trying) to simulate what we need to know using the beta rendering platform in OnShape. Time will tell if we have enough control over the position and nature of the light source to make this useful.
I expect that whatever I make with featurescript will just be a convenience tool, but that a real optical package will be important for validation of anything complex. I doubt that I'll get into anything like internal scattering. Even surface scattering is a stretch for me.
I've gotten back into the idea of a clean re-write. I'll keep you posted if I get that done.
Good luck on the re-write. Thanks again.
Did you manage to come to a conclusion on your original question @John_Christiansen ? I'm also needing a solution to this now!