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.

Options

Implementing Snell's Law in a sketch

mac_frolic077mac_frolic077 Member Posts: 2
Hi

I wonder if there is a way to define a constraint between lines that represent the law of refraction?

i.e. I have a line with a point that represents the border of two mediums (air and glass). I want to draw a line that represents a ray of light that hits the surface in a certain angle. and I want to draw a line that represents the ray refracted inside the medium.

something like this:

https://www.geogebra.org/m/WnaEUHzW

I also want to be able to extend it to see how the refraction of a prism would influence the path of a ray.

in terms of the above example (after the link) angle phi is a function of angle alpha and the refraction-index of the two materials.

so what I am looking for is a constraint that can be defined by a function.

I know there is featurescript, but I have no experience with it. if this scripting language can help me with this problem, I would be glad if somebody can point me in the right direction, i.e. a script that can do something similar.

cheers

martin

Comments

  • Options
    paul_chastellpaul_chastell Onshape Employees Posts: 124
    How about this example of a ray tracer, which allows for setting of refraction indices and traces a ray through parts.
    https://cad.onshape.com/documents/258a19506c555f400614c944/w/74e657ae2800105e2874589a/e/71d75b30fc9a22f4a9b82a08
    Paul Chastell
    TVP, Onshape R&D
  • Options
    mahirmahir Member, Developers Posts: 1,291 ✭✭✭✭✭
    edited April 2018
    You can't use formulas/equations on a dimension directly, but you can do so indirectly with variables. First, create 4 variables - Th1, Th2, N1, and N2 (or whatever you want to call them. Th1/N1/N2 will be your inputs. Set Th2 equal to asin(N1/N2*sin(Th1). Make sure to use proper degree units. Now in a sketch, you can set your input angle to #Th1 and your output angle to #Th2. That should accomplish what you're trying to do. You will be able to vary your prism medium (N2) and input angle (Th1) and see the effect on your refracted angle (Th2).
  • Options
    philip_thomasphilip_thomas Member, Moderator, Onshape Employees, Developers Posts: 1,381
    This is a fun one - (uses the Ray Trace custom feature). Try experimenting with the option to show BOTH reflected and refracted rays (you will likely have to bump up the number of 'bounces' significantly as its recursive).

    https://cad.onshape.com/documents/109847f3ca92fbe0b164942e/w/07c893ecde8849e9ad780149/e/62ff57faac476c02966bed8f



    Philip Thomas - Onshape
Sign In or Register to comment.