Sketcher BSplinePoleWeight: Difference between revisions

From FreeCAD Documentation
(more info - more to come)
(more info)
Line 35: Line 35:
{{Caption|Same B-spline without weights}}
{{Caption|Same B-spline without weights}}


==Explanation==
The weights determine how the control points are taken into account. The term weight is hereby a bit misleading because in literature the coordinates of the control points are often described as weights since they appear as factor in the definition of the Bézier curves:

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).

The Bézier curve is calculated using this formula:


<math>\quad
<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{w_{i}}_{\text{weight}}
\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>
</math>


''n'' is hereby the degree of the curve. So a Bézier curve of degree ''n'' is a polygon with order ''n''. 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).
''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].


The spline weight in FreeCAD is however something different. The idea is to modify the spline so that the different control points are "weighted". So a point with weight 2 should have twice as much influence than a point with weight 1. This is achieved by using this formula to calculate the spline:
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:


<math>\quad
<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{w_{i}}_{\text{weight}}
\textrm{Rational Bezier}(n,t)=\cfrac{\sum_{i=0}^{n}\binom{n}{i}\left(1-t\right)^{n-i}t^{i}P_{i}w_{i}}{\sum_{i=0}^{n}\binom{n}{i}\left(1-t\right)^{n-i}t^{i}w_{i}}
</math>
</math>


whereby <math>w_{i}</math> is the weight for the point <math>P_{i}</math>.


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.


Therefore, 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:
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>
</translate>
Line 58: Line 64:
{{Caption|Same B-spline as in first image but with different absolute weight values}}
{{Caption|Same B-spline as in first image but with different absolute weight values}}


A weight of zero would be a singularity in equation??, therefore FreeCAD assures that it cannot become zero. Nevertheless, small values have the same effect as if the control point would almost not exist:
A weight of zero would be a singularity in the equation to calculate the ration 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>
</translate>
[[File:sketcher_BSplineWeightZero.png|468px]]
[[File:sketcher_BSplineWeightZero.png|468px]]
<translate>
<translate>
{{Caption|Same B-spline with a zero weight control point}}
{{Caption|Same B-spline with an almost zero weight control point}}


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

Revision as of 01:58, 9 November 2020

Sketcher BSplinePoleWeight

Menu location
Sketch → Sketcher B-spline tools → Show/Hide B-spline control point weight
Workbenches
Sketcher
Default shortcut
None
Introduced in version
0.19
See also
Create B-spline

Description

Shows or hides the display of the weight for the control points of a B-spline curve (see B-spline).

B-spline with control point weights displayed in brackets

File:Sketcher BSplineWeightHide.png

Same B-spline without weights

Explanation

B-splines are basically a combination of Bézier curves (nicely explained in this and this video).

The Bézier curve is calculated using this formula:

n is hereby the degree of the curve. So a Bézier curve of degree n is a polygon with order n. The factors are hereby in fact the coordinates of the Bézier curves' control points. For a visualization see this page.

The term weight in FreeCAD is a bit misleading because in literature the factors 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:

whereby is the weight for the point .

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.

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:

Same B-spline as in first image but with different absolute weight values

A weight of zero would be a singularity in the equation to calculate the ration 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:

Same B-spline with an almost zero weight control point

Usage

  1. Select a B-spline and apply.