FreeCAD Logo FreeCAD 1.0
  • English Afrikaans Arabic Belarusian Catalan Czech German Greek Spanish Spanish Basque Finnish Filipino French Galician Croatian Hungarian Indonesian Italian Japanese Kabyle Korean Lithuanian Dutch Norwegian Bokmal Polish Portuguese Portuguese Romanian Russian Slovak Slovenian Serbian Swedish Turkish Ukrainian Valencian Vietnamese Chinese Chinese
  • Features
  • Download
  • Blog
  • Documentation
    Documentation index Getting started Users documentation The FreeCAD manual Workbenches documentation Python coding documentation C++ coding documentation Tutorials Frequently asked questions Privacy policy About FreeCAD
  • Contribute
    How to help Sponsor Report a bug Make a pull request Jobs and funding Contribution guidelines Developers handbook Translations
  • Community
    Code of conduct Forum The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Calendar
  • ♥ Donate

Donate

$
SEPA Information
Please set up your SEPA bank transfer to:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Bank agency: BNP Paribas Fortis
Address: Rue de la Station 64, 1360 Perwez, Belgium

While Stripe doesn't support monthly donations, you can still become a sponsor! Simply make a one-time donation equivalent to 12 months of support, and you'll gain access to the corresponding sponsoring tier. It's an easy and flexible way to contribute.

If you are not sure or not able to commit to a regular donation, but still want to help the project, you can do a one-time donation, of any amount.

Choose freely the amount you wish to donate one time only.

You can support FreeCAD by sponsoring it as an individual or organization through various platforms. Sponsorship provides a steady income for developers, allowing the FPA to plan ahead and enabling greater investment in FreeCAD. To encourage sponsorship, we offer different tiers, and unless you choose to remain anonymous, your name or company logo will be featured on our website accordingly.

from 1 USD / 1 EUR per month. You will not have your name displayed here, but you will have helped the project a lot anyway. Together, normal sponsors maintain the project on its feet as much as the bigger sponsors.

from 25 USD / 25 EUR per month. Your name or company name is displayed on this page.

from 100 USD / 100 EUR per month. Your name or company name is displayed on this page, with a link to your website, and a one-line description text.

from 200 USD / 200 EUR per month. Your name or company name and logo displayed on this page, with a link to your website and a custom description text. Companies that have helped FreeCAD early on also appear under Gold sponsors.

Instead of donating each month, you might find it more comfortable to make a one-time donation that, when divided by twelve, would give you right to enter a sponsoring tier. Don't hesitate to do so!

Choose freely the amount you wish to donate each month.

Please inform your forum name or twitter handle as a notein your transfer, or reach to us, so we can give you proper credits!


GuiCommand: Name: Sketcher ConstrainSnellsLaw MenuLocation: Sketch , Sketcher constraints , Constrain refraction Workbenches: Sketcher_Workbench Shortcut: K W Version: 0.15

Sketcher ConstrainSnellsLaw

Description

The Sketcher ConstrainSnellsLaw tool constrains two lines to follow the law of refraction of light as it penetrates through an interface where two materials with different refraction indices meet. See Snell\'s law.

*Snell's Law*

Usage

*The sequence of clicks is indicated by yellow arrows with numbers, n1 and n2 show where the indices of refraction are*
  1. Prepare two lines to represent a beam of light, and an edge to act as an interface. The lines should be on different sides of the interface. The interface can be a line, an arc, a circle or a conic.
  2. Select an endpoint of the first line, an endpoint of the second line, and the interface edge. Note the selection order of the endpoints.
  3. There are several ways to invoke the tool:
    • Select the Sketch → Sketcher constraints → Constrain refraction (Snell's law) option from the menu.
    • Use the keyboard shortcut: K then W.
  4. The Refractive index ratio dialog opens.
  5. Enter the Ratio n2/n1. Where n2 is for the medium where the second selected line resides, and n1 is for the first line\'s medium.
  6. A Snell\'s law constraint is added. If required the endpoints are made coincident and constrained onto the interface. These additional constraints are called helper constraints.

Notes

  • The actual Snell\'s law constraint enforces the plain law equation n1*sin(theta1) = n2*sin(theta2). It needs the line ends to be made coincident and on the interface by other constraints, otherwise the behavior is undefined. The necessary helper constraints are added automatically based on the current coordinates of the elements.
  • In Python the helper constraints must be added manually (see Scripting).
  • These helper constraints can be temporarily deleted and the endpoints dragged apart, which can be useful in case one wants to construct a reflected ray or birefringence rays.
  • Unlike the reality, refraction indices are associated with rays of light, but not according to the sides of the boundary. This is useful to emulate birefringence, construct paths of different wavelengths due to refraction, and easily construct angle of onset of total internal reflection.
  • Both rays can be on the same side of the interface, satisfying the constraint equation. This is physical nonsense, unless the ratio n2/n1 is 1.0, in which case the constraint emulates a reflection.
  • Arcs of circle and ellipse are also accepted as rays. But this is also physical nonsense.

Scripting

The constraints can be created from macros and from the Python console by using the following function:

Sketch.addConstraint(Sketcher.Constraint('SnellsLaw',line1,pointpos1,line2,pointpos2,interface,n2byn1))

where:

  • Sketch is a sketch object

  • line1 and pointpos1 are two integers identifying the endpoint of the line in medium with refractive index of n1. line1 is the line\'s index in the sketch (the value, returned by Sketch.addGeometry), and pointpos1 should be 1 for start point and 2 for end point.

  • line2 and pointpos2 are the indexes specifying the endpoint of the second line (in medium n2)

  • interface is the index specifying the line indicating the position of the interface between medium n1 and medium n2

  • n2byn1 is a floating-point number equal to the ratio of refractive indices n2/n1

The Sketcher scripting page explains the values which can be used for line1, pointpos1, line2, pointpos2 and interface and contains further examples on how to create constraints from Python scripts.

Example:

import Sketcher
import Part
import FreeCAD

StartPoint = 1
EndPoint = 2

f = App.activeDocument().addObject("Sketcher::SketchObject","Sketch")

# add geometry to the sketch
icir = f.addGeometry(Part.Circle(App.Vector(-547.612366,227.479736,0),App.Vector(0,0,1),68.161979))
iline1 = f.addGeometry(Part.LineSegment(App.Vector(-667.331726,244.127090,0),App.Vector(-604.284241,269.275238,0)))
iline2 = f.addGeometry(Part.LineSegment(App.Vector(-604.284241,269.275238,0),App.Vector(-490.940491,256.878265,0)))
# add constraints
# helper constraints:
f.addConstraint(Sketcher.Constraint('Coincident',iline1,EndPoint,iline2,StartPoint)) 
f.addConstraint(Sketcher.Constraint('PointOnObject',iline1,EndPoint,icir)) 
# the Snell's law:
f.addConstraint(Sketcher.Constraint('SnellsLaw',iline1,EndPoint,iline2,StartPoint,icir,1.47))

App.ActiveDocument.recompute() 

⏵ documentation index > Sketcher > Sketcher ConstrainSnellsLaw

This page is retrieved from https://github.com/FreeCAD/FreeCAD-documentation/blob/main/wiki/Sketcher_ConstrainSnellsLaw.md

Get in touch!
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

© The FreeCAD Team. Homepage image credits (top to bottom): ppemawm, r-frank, epileftric, regis, rider_mortagnais, bejant.

This project is supported by: , KiCad Services Corp. and other sponsors

GitHubImprove this page on GitHub