Draft: Curva di Bézier cubica

From FreeCAD Documentation
Revision as of 20:58, 20 September 2019 by Renatorivo (talk | contribs)

Curva di Bézier cubica

Posizione nel menu
Draft → Strumenti Bezier → Curva di Bézier cubica
Ambiente
Draft, Arch
Avvio veloce
Nessuno
Introdotto nella versione
-
Vedere anche
Polilinea, B-spline, Curva di Bézier

Descrizione

Lo strumento Curva di Bézier cubica crea unaCurva di Bézier di terzo grado (sono richiesti quattro punti). Questa è una delle curve di Bezier più usate nelle applicazioni di computer grafica. Questo strumento consente di creare una grande spline composta da diversi segmenti Bezier di 3° grado, in un modo simile allo strumento Bezier in Inkscape. Una curva generica di Bezier di qualsiasi grado può essere creata con lo strumento Curva di Bézier.

Gli strumenti Curva di Bézier e Curva di Bézier cubica utilizzano i punti di controllo per definire la posizione e la curvatura della spline; invece lo strumento B-spline specifica i punti esatti attraverso i quali passa la curva.

Curva di Bézier cubica definita da tre punti di controllo

Utilizzo

  1. Premere il pulsante Curva di Bézier cubica.
  2. Fare clic su un primo punto nella vista 3D e tenere premuto il puntatore del mouse.
  3. Trascinare il puntatore su un altro punto della vista 3D e rilasciare il puntatore.
  4. Spostare il puntatore su un altro punto della vista 3D per regolare la curvatura della spline, fare clic e tenere premuto sul punto.
  5. Spostare il puntatore su un altro punto della vista 3D per regolare la curvatura finale della spline, quindi rilasciare il puntatore. Questo crea una curva di Bezier di 3° grado. Continuare a disegnare dall'ultimo punto.
  6. Ripetere il processo di fare clic, tenere premuto, trascinare e rilasciare per aggiungere punti e creare ulteriori segmenti Beziér di terzo grado.
  7. Premere Esc o il pulsante Chiudi per completare l'edizione.

Note that with this workflow you need two click-hold-release sequences to create a single Bezier curve of third degree.

  • The first click-hold defines the first end point.
  • The first release defines the first control point.
  • The second click-hold defines the second end point, and the general direction of the spline.
  • The second release defines the final curvature of the spline.
  • The second control point is not explicitly given, but is determined from the location of the pointer during the second release.

Note when creating many Bezier segments

  • The second release also correspond to the first control point of the subsequent Bezier curve.
  • This means that the second click-hold was also the first end point of the second Bezier curve.
  • A third click-hold would be the second end point.
  • A third release would define the final curvature of the second curve, and it would also be the first control point of a third curve.

This means that for every two click-hold (c-h) and release (r) sequences, the second sequence is already part of a subsequent curve segment, as indicated in the following graphic:

|c-h -- r -- c-h -- r| 1
            |c-h -- r -- c-h -- r| 2
                        |c-h -- r -- c-h -- r| 3
                                    |c-h -- r -- c-h -- r| 4

How to place the control points exactly

The graphical operation of this tool only allows the user to specify the first control point of the curve when it is being drawn. The second control point can be adjusted after the object is created: double click on the curve object in tree view, or select it and press Edit. Then drag the second control point to the desired position.

In order to choose exactly both end points and both control points, the Python command Draft.makeBezCurve() must be used. See the Scripting section.

Opzioni

See the options in Draft BezCurve.

Proprietà

See the properties in Draft BezCurve.

Script

Vedere anche: Draft API e Nozioni di base sugli script di FreeCAD.

Per informazioni di carattere generale vedere Curva di Bézier. Una Bezier cubica viene creata passando l'opzione degree=3 a makeBezCurve().

Per ogni segmento di Bezier cubica devono essere utilizzati quattro punti, di cui i due punti intermedi sono i punti di controllo.

  • Se vengono assegnati solo 3 punti, viene creata una Bezier quadratica.
  • Se vengono assegnati solo 2 punti, viene creata una Bezier lineare, ovvero una linea retta.
  • Se vengono assegnati 5 punti, i primi 4 creano un segmento di Bezier cubico; il quarto e il quinto punto vengono utilizzati per creare una linea retta.
  • Se vengono assegnati 6 punti, i primi 4 creano un segmento cubico di Bezier; il quarto e gli altri due punti vengono utilizzati per creare un segmento quadratico di Bezier.
  • Se vengono assegnati 7 punti, i primi 4 creano un segmento cubico di Bezier; il quarto e gli altri tre sono usati per creare un secondo segmento cubico di Bezier.
  • Cioè, quando possibile, l'ultimo punto in una Bezier cubica è condiviso con i punti seguenti.

Examples of Bezier curves produced by using 2, 3, 4, 5, 6, 7, and 8 points. The solid lines indicate cubic Bezier segments; the other lines are quadratic or linear.

Esempio:

import FreeCAD as App
import Draft

p1 = App.Vector(-3500, 0, 0)
p2 = App.Vector(-3000, 2000, 0)
p3 = App.Vector(-1100, 2000, 0)
p4 = App.Vector(0, 0, 0)

p5 = App.Vector(1500, -2000, 0)
p6 = App.Vector(3000, -1500, 0)
p7 = App.Vector(5000, 0, 0)
p8 = App.Vector(6000, 1500, 0)
rot = App.Rotation()

c1 = Draft.makeCircle(100, placement=App.Placement(p1, rot), face=False)
c1.Label = "B1_E1"
c2 = Draft.makeCircle(50, placement=App.Placement(p2, rot), face=True)
c2.Label = "B1_c1"
c3 = Draft.makeCircle(50, placement=App.Placement(p3, rot), face=True)
c3.Label = "B1_c2"
c4 = Draft.makeCircle(100, placement=App.Placement(p4, rot), face=False)
c4.Label = "B1_E2"
c5 = Draft.makeCircle(50, placement=App.Placement(p5, rot), face=True)
c5.Label = "B2_c3"
c6 = Draft.makeCircle(50, placement=App.Placement(p6, rot), face=True)
c6.Label = "B2_c4"
c7 = Draft.makeCircle(100, placement=App.Placement(p7, rot), face=False)
c7.Label = "B2_E3"
c8 = Draft.makeCircle(50, placement=App.Placement(p8, rot), face=True)
c8.Label = "B3_c5"
App.ActiveDocument.recompute()

B1 = Draft.makeBezCurve([p1, p2], degree=3)
B1.Label = "B_lin"
B1.ViewObject.DrawStyle = "Dashed"

B2 = Draft.makeBezCurve([p1, p2, p3], degree=3)
B2.Label = "B_quad"
B2.ViewObject.DrawStyle = "Dotted"

B3 = Draft.makeBezCurve([p1, p2, p3, p4], degree=3)
B3.Label = "B_cub"
B3.ViewObject.LineWidth = 4

B4 = Draft.makeBezCurve([p1, p2, p3, p4, p5], degree=3)
B4.Label = "B_cub+lin"
B4.ViewObject.DrawStyle = "Dashed"

B5 = Draft.makeBezCurve([p1, p2, p3, p4, p5, p6], degree=3)
B5.Label = "B_cub+quad"
B5.ViewObject.DrawStyle = "Dotted"

B6 = Draft.makeBezCurve([p1, p2, p3, p4, p5, p6, p7], degree=3)
B6.Label = "B_cub+cub"
B6.ViewObject.LineWidth = 2

B7 = Draft.makeBezCurve([p1, p2, p3, p4, p5, p6, p7, p8], degree=3)
B7.Label = "B_cub+cub+lin"
B7.ViewObject.DrawStyle = "Dashed"
App.ActiveDocument.recompute()