Draft KubischeBézierkurve

From FreeCAD Documentation
Revision as of 17:56, 21 February 2020 by FuzzyBot (talk | contribs) (Updating to match new version of source page)

Entwurf Kubische Bézierkurve

Menüeintrag
Draft → Bezier tools → CubicBezCurve
Arbeitsbereich
Draft, Arch
Standardtastenkürzel
Keiner
Eingeführt in Version
0.19
Siehe auch
Draft Wire, Draft BSpline, Draft BezCurve

Beschreibung

Das Werkzeug CubicBezCurve erstellt eine Bezier-Kurve dritten Grades (vier Punkte erforderlich). Dies ist eine der am häufigsten verwendeten Kurven in Computergrafikanwendungen. Mit diesem Werkzeug können Sie eine große Spline aus mehreren Beziersegmenten 3. Grades erstellen, ähnlich dem Bezierwerkzeug in Inkscape. Eine allgemeine Bezier-Kurve beliebigen Grades kann mit Draft BezCurve erstellt werden.

Das Werkzeug Draft BezCurve und die Werkzeuge Draft CubicBezCurve verwenden Kontrollpunkte, um die Position und Krümmung der Spline zu definieren; andererseits spezifiziert das Werkzeug Draft BSpline die genauen Punkte, durch die die Kurve verläuft.

Spline, definiert durch drei kubische Beziersegmente. Jeder kubische Bezier ist durch vier Punkte definiert, aber wenn das Werkzeug grafisch verwendet wird, werden nur drei solcher Punkte platziert: 1-2-3 für das erste Segment, 3-4-5-5 für das zweite Segment und 5-6-7 für das dritte Segment; der vierte Punkt in jedem Segment ist implizit definiert; der letzte Punkt 8 ist notwendig, um den Vorgang abzuschließen, und wäre Teil eines vierten Bezier-Segments, wenn der Vorgang fortgesetzt wird.

Anwendung

  1. Drücke die Taste Draft CubicBezCurve
  2. Klicke auf einen ersten Punkt in der 3D Ansicht und halte die Maustaste (1) gedrückt; dies ist der erste Endpunkt.
  3. Ziehe den Mauszeiger an einen anderen Punkt in der 3D Ansicht und lasse die Maustaste los (2); dies ist der erste Kontrollpunkt.
  4. Bewege den Zeiger auf einen anderen Punkt in der 3D Ansicht und klicke und halte die Maustaste auf diesen Punkt (3); dies ist der zweite Endpunkt.
  5. Bewege den Zeiger auf einen anderen Punkt in der 3D-Ansicht, um die endgültige Krümmung der Spline anzupassen, und lasse dann die Maustaste (4) los.
  6. In diesem Moment hast du bereits eine Bezier-Kurve von 3. Grad. Der Befehl kann durch Drücken von Esc oder der Taste Close abgeschlossen werden, oder Du kannst den Prozess des Klickens und Haltens (5) und des Ziehens und Loslassens (6) wiederholen, um weitere Bezier-Segmente dritten Grades hinzuzufügen.

Beachte, dass Du bei diesem Arbeitsablauf zwei Click-Hold-Release-Sequenzen benötigst, um eine einzelne Bezierkurve dritten Grades zu erstellen.

  • Das erste Klick-Halten definiert den ersten Endpunkt.
  • Die erste Version definiert den ersten Kontrollpunkt.
  • Das zweite Klick-Halten definiert den zweiten Endpunkt und die allgemeine Richtung der Spline.
  • Die zweite Version definiert die endgültige Krümmung der Spline.
  • Der zweite Kontrollpunkt ist nicht explizit angegeben, sondern wird aus der Position des Zeigers während der zweiten Freigabe bestimmt.

Hinweis wenn viele Bezier-Segmente erstellt werden

Creating several 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 exactly place the control points

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.

Options

See the options in Draft BezCurve.

Properties

See the properties in Draft BezCurve.

Scripting

See also: Draft API and FreeCAD Scripting Basics.

See Draft BezCurve for the general information. A cubic Bezier is created by passing the option degree=3 to makeBezCurve().

For each cubic Bezier segment four points must be used, of which the two extreme points indicate where the spline passes through, and the two intermediate points are control points.

  • If only 3 points are given, it creates a quadratic Bezier instead, with only one control point.
  • If only 2 points are given, it creates a linear Bezier, that is, a straight line.
  • If 5 points are given, the first 4 create a cubic Bezier segment; the 4th and the 5th points are used to create a straight line.
  • If 6 points are given, the first 4 create a cubic Bezier segment; the 4th and the other two points are used to create a quadratic Bezier segment.
  • If 7 points are given, the first 4 create a cubic Bezier segment; the 4th and the other three points are used to create a second cubic Bezier segment.
  • In general, the last point in a group of four is shared with the following three points maximum to create another Bezier segment.
  • To have smooth curves, with no straight segments, the number of points should be 3n + 1 or 3n, where n is the number of segments, for n >= 1.

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.

Example:

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