Sketcher BSplinePoleWeight: Difference between revisions

From FreeCAD Documentation
(remove unnecessary image (keep the docs simple, my mistake that I once added it))
(Removed the "Weight explanation" paragraph. Does not belong here.)
(24 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
{{Page_in_progress}}
<translate>
<translate>

<!--T:10-->
<!--T:10-->
{{Docnav
{{Docnav
|[[Sketcher_BSplineKnotMultiplicity| Show/Hide B-spline knot multiplicity]]
|[[Sketcher_BSplineKnotMultiplicity|Show/hide B-spline knot multiplicity]]
|[[Sketcher_ArcOverlay|Show/hide circular helper for arcs]]
|[[Sketcher_BSplineConvertToNURB|Convert Geometry to B-spline]]
|[[Sketcher_Workbench|Sketcher]]
|[[Sketcher_Workbench|Sketcher]]
|IconL=Sketcher_BSplineKnotMultiplicity.svg
|IconL=Sketcher_BSplineKnotMultiplicity.svg
|IconR=Sketcher_BSplineConvertToNURB.svg
|IconR=Sketcher_ArcOverlay.svg
|IconC=Workbench_Sketcher.svg
|IconC=Workbench_Sketcher.svg
}}
}}
Line 14: Line 16:
{{GuiCommand
{{GuiCommand
|Name=Sketcher BSplinePoleWeight
|Name=Sketcher BSplinePoleWeight
|MenuLocation=Sketch → Sketcher B-spline tools → Show/Hide B-spline control point weight
|MenuLocation=Sketch → Sketcher visual → Show/hide B-spline information layer → Show/hide B-spline control point weight
|Workbenches=[[Sketcher_Workbench|Sketcher]]
|Workbenches=[[Sketcher_Workbench|Sketcher]]
|Version=0.19
|Version=0.19
|SeeAlso=[[Sketcher_CompCreateBSpline|Sketcher Create B-spline]]
|SeeAlso=[[Sketcher_CreateBSpline|Sketcher CreateBSpline]]
}}
}}


Line 23: Line 25:


<!--T:9-->
<!--T:9-->
Shows or hides the display of the '''weights''' for the control points of a B-spline curve (see [[#Explanation|below]] for an explanation of weights).
The [[Image:Sketcher_BSplinePoleWeight.svg|24px]] [[Sketcher_BSplinePoleWeight|Sketcher BSplinePoleWeight]] tool shows or hides the B-spline control point weight in all sketches. See [[#Weight_explanation|below]] for an explanation about weights.


</translate>
</translate>
Line 29: Line 31:
<translate>
<translate>
<!--T:14-->
<!--T:14-->
{{Caption|B-spline with control point weights displayed in brackets}}
{{Caption|The numbers (green, in square brackets) refer to the weights of the control points.}}


==Usage== <!--T:5-->
==Usage== <!--T:5-->


<!--T:13-->
<!--T:13-->
# There are several ways to invoke the tool:
# Select a B-spline and apply.
#* Press the {{Button|[[Image:Sketcher_BSplinePoleWeight.svg|16px]] [[Sketcher_BSplinePoleWeight|Show/hide B-spline control point weight]]}} button.

#* Select the {{MenuCommand|Sketch → Sketcher visual → Show/hide B-spline information layer → [[Image:Sketcher_BSplinePoleWeight.svg|16px]] Show/hide B-spline control point weight}} option from the menu.
==Explanation== <!--T:16-->

<!--T:17-->
B-splines are basically a combination of [https://en.wikipedia.org/wiki/Bezier_curve#Constructing_B%C3%A9zier_curves Bézier curves] (nicely explained in [https://www.youtube.com/watch?v=bE1MrrqBAl8 this] and [https://www.youtube.com/watch?v=xXJylM2S72s this] video).

<!--T:18-->
The Bézier curve is calculated using this formula:

<!--T:19-->
<math>\quad
\textrm{Bezier}(n,t)=\sum_{i=0}^{n}\underbrace{\binom{n}{i}}_{\text{polynomial term}}\underbrace{\left(1-t\right)^{n-i}t^{i}}_{\text{polynomial term}}\; \underbrace{P_{i}}_{\text{point coordinate}}
</math>

<!--T:20-->
''n'' is hereby the degree of the curve. So a Bézier curve of degree ''n'' is a polygon with order ''n''. The factors <math>P_{i}</math> are hereby in fact the coordinates of the Bézier curves' control points. For a visualization see [https://pomax.github.io/bezierinfo/#control this page].

<!--T:21-->
The term weight in FreeCAD is a bit misleading because in literature the factors <math>P_{i}</math> are often called weights as well. FreeCAD's weights are something different. The idea of these weights is to modify the spline so that the different control points are "weighted". The idea is that a point with weight 2 should have twice as much influence than a point with weight 1. This is achieved by using this different formula to calculate the spline:

<!--T:22-->
<math>\quad
\textrm{Rational Bezier}(n,t)=\cfrac{\sum_{i=0}^{n}\binom{n}{i}\left(1-t\right)^{n-i}t^{i}w_{i}P_{i}}{\sum_{i=0}^{n}\binom{n}{i}\left(1-t\right)^{n-i}t^{i}w_{i}\;\;\;\,}
</math>

<!--T:23-->
whereby <math>w_{i}</math> is the weight for the point <math>P_{i}</math>.

<!--T:24-->
This is a new class of Bézier curves because despite the points are indeed weighted as desired, the curve is no longer a polynomial but a fractional polynomial. Therefore these curves are called rational Bézier curves and the B-splines is then called rational B-splines.

<!--T:25-->
The consequence is that you gain more flexibility in defining the spline shape. If all weights are equal, the shape of the spline does not change. So the weights relative to each other is important, not the value alone. For example this spline has exactly the same shape as the one in the first image:

</translate>
[[File:sketcher_BSplineWeightDouble.png|468px]]
<translate>
<!--T:26-->
{{Caption|Same B-spline as in first image but with different absolute weight values}}

<!--T:27-->
A weight of zero would be a singularity in the equation to calculate the rational Bézier curves, therefore FreeCAD assures that it cannot become zero. Nevertheless, small values have the same effect as if the control point would almost not exist:

</translate>
[[File:sketcher_BSplineWeightZero.png|468px]]
<translate>
<!--T:28-->
{{Caption|Same B-spline with an almost zero weight control point}}


==Creation== <!--T:29-->
==Changing weights== <!--T:29-->


<!--T:30-->
<!--T:30-->
How to change weights is described on [[B-Splines#Changing_the_Weight|this page]].
Rational B-splines are created by setting a radius for the circles of the control points. That a radius has a unit must hereby ignored, the weight is always the radius in mm (or in the base length unit you set [[Preferences_Editor#Units|in the preferences]]). So a radius of 1 µm means a weight of 0.001.
By default, meaning on creation time, all circles have the constraint to be equal. For the radius of the circle of the first point FreeCAD automatically sets a size constraint. Since all circles have the same radius, the set value is not important. So after creation you have a non-rational ("normal") B-spline.


<!--T:31-->
To set a weight, remove the equality constraint for the circle of the desired point. You can now drag the circle to see the effect on changing its radius.<br/>'''But note:''' to set the weight fix so that further actions won't change it, you must set a size constraint.


<!--T:8-->
<!--T:8-->
{{Docnav
{{Docnav
|[[Sketcher_BSplineKnotMultiplicity|Show/Hide B-spline knot multiplicity]]
|[[Sketcher_BSplineKnotMultiplicity|Show/hide B-spline knot multiplicity]]
|[[Sketcher_ArcOverlay|Show/hide circular helper for arcs]]
|[[Sketcher_BSplineConvertToNURB|Convert Geometry to B-spline]]
|[[Sketcher_Workbench|Sketcher]]
|[[Sketcher_Workbench|Sketcher]]
|IconL=Sketcher_BSplineKnotMultiplicity.svg
|IconL=Sketcher_BSplineKnotMultiplicity.svg
|IconR=Sketcher_BSplineConvertToNURB.svg
|IconR=Sketcher_ArcOverlay.svg
|IconC=Workbench_Sketcher.svg
|IconC=Workbench_Sketcher.svg
}}
}}


</translate>
</translate>
{{Sketcher Tools navi{{#translation:}}}}
{{Sketcher_Tools_navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{clear}}

Revision as of 08:39, 18 April 2024

This documentation is a work in progress. Please don't mark it as translatable since it will change in the next hours and days.

Sketcher BSplinePoleWeight

Menu location
Sketch → Sketcher visual → Show/hide B-spline information layer → Show/hide B-spline control point weight
Workbenches
Sketcher
Default shortcut
None
Introduced in version
0.19
See also
Sketcher CreateBSpline

Description

The Sketcher BSplinePoleWeight tool shows or hides the B-spline control point weight in all sketches. See below for an explanation about weights.

The numbers (green, in square brackets) refer to the weights of the control points.

Usage

  1. There are several ways to invoke the tool:
    • Press the Show/hide B-spline control point weight button.
    • Select the Sketch → Sketcher visual → Show/hide B-spline information layer → Show/hide B-spline control point weight option from the menu.

Changing weights

How to change weights is described on this page.