Sketcher Tutorial

This tutorial is work in progress!

Introduction
The Sketcher is a tool to generate 2D-objects for usage in parts design. The sketcher is different to traditional drawing tools. A way to show the difference is the construction of a triangle. A triangle is fully defined by 3 values, which can be any from the following list: side length, angle, height, area. The one exception is three angles, which will not define the size.

In order to construct a triangle from 3 length in the traditional way, the following has to be done:
 * draw the base line
 * make two circles with a radius given by the other two side lengths, or alternatively calculate the coordinates of the third vertex
 * draw the missing two sides from the endpooints of the base line to the crossing point of the two circles or the calculated vertex.



The Triangle page shows a collection of formulas to calculate the missing information in order to draw a triangle from the minimum specification. Those are needed, if the triangle has to be defined by precalculated coordinates.

The Sketcher is different. The formulas and helper constructions are not needed. Instead in the Sketcher an arbitrary triangle will be drawn with the polyline tool. The triangle needs to be closed. So for the last line a click is needed on the first created vertex. A point should be visible near the mouse pointer before clicking. Image??

This will make sure, that the last vertex is identical to the first one. The created triangle is flexible. A vertex can be selected by clicking on it, so it turns green. Then this vertex can be dragged around. The triangle may move or rotate and the sides may change their length.

Each lenght of the side is now easy defined by selecting it and then clicking on the length tool. A dialog opens and the wanted length can be put in. The picture below shows a triangle with side lengths of 35 mm, 27 mm and 25 mm.

These length-definitions are called constraints. Constraints are used to define a fixed design from the flexible geometric input. The sketcher provides all constraints needed to define any kind of tringle. Only the area can not be used to define one. Here is a list of cases:


 * One or two angles given: Two sides of the triangle needs to be selected. A click on [[Image:Constraint_InternalAngle.png|32px]] opens a dialog to define the angle.


 * Right triangle: Two sides of the triangle needs to be selected. A click on[[Image:Constraint_Perpendicular.png|32px]] sets a right angle between the two sides.


 * Equilateral: One side has to be set to a defined length. Then all sides needs to be selected. A click on[[Image:Constraint_EqualLength.png|32px]] defines two equal length constrains in order to give all sides the same length.


 * Isosceles triangle (two identical length) with given height: Select first the two vertices of the base line and last the symmetric vertex. A click on [[Image:Constraint_Symmetric.png|32px]] sets a symmetry between the three vertices. Then select the base line and the symmetry vertex and click the [[Image:Constraint_Length.png|32px]] length tool.

Fixing the triangle to a location. Align it.

More themes:

Profiles for solid parts
closed profiles no intersection of lines

Construction lines
helper lines to define more complex profiles

external Geometry
see link Sketcher_External

More about Constraints
The sketcher does not know the triangle formulas from the wikipedia. Instead it sets up an equation system for the 2-dimensional coordinates based on the given constraints. This equations system is then solved numerically.

In this way a wide variety of geometric problem can be solved. But there is also a disadvantage. If the set of equations has multiple solutions, we may get something totally different from what we expect. This is especially annoying, if the same design should be used for different dimensions. So after a change of a length constraint the sketch flips to something totally different. An example is the division of a distance into three equal partitions. The following picture shows three lines in a row with equalty and parallel constraint set.

Image This works well, as long as only larger distance are put in. When the distance is reduced above a certain ratio, the lines are folding together. So we do not get anymore a third of the given distance but the distance itself or two third of it. Some lines of our row have thanged their orientation. This gives still a valid solution for the set of constraints, but is not what was intended.

Image folded row

A solution is to define an angle of 180° between the lines. This constraint has only one solution. The sketch is robust against large changes of the distance. Image 180°

Another possible approch to make three equal partitions, is to nest two symmetries. Image Experience show, that this approach is a hard numerical problem for the solver. The sketch may freeze. This approach should be avoided.

Another problem is the change of orientation of angles. This can happen if, angle changes above 180° are made.

So in general it can be recommended, to set the constraints in a clear tree dependency. Circle dependencies are more problematic.

Often there are more than one possibility to set a constraint. Those should be selected, that have only solution for the geometry.