Skip to main content
Commonmark migration
Source Link

SplineDegree -> d specifies that the underlying polynomial basis should have maximal degree d.

 

Method is a option that determining which algorithm was used.

 

ControlPoints is a option that determining whether show the control points

 

SplineClosed is an option that specifies whether spline curves or surfaces should be closed.

 

CAGDBezierCurve by default represents a composite cubic Bézier curve.

 

With SplineDegree -> d, CAGDBezierCurve with d + 1 control points yields a simple degree - d Bézier curve.With fewer control points, a lower - degree curve is generated. With more control points, a composite Bézier curve is generated.

###TEST

TEST

###QUESTION

QUESTION

SplineDegree -> d specifies that the underlying polynomial basis should have maximal degree d.

 

Method is a option that determining which algorithm was used.

 

ControlPoints is a option that determining whether show the control points

 

SplineClosed is an option that specifies whether spline curves or surfaces should be closed.

 

CAGDBezierCurve by default represents a composite cubic Bézier curve.

 

With SplineDegree -> d, CAGDBezierCurve with d + 1 control points yields a simple degree - d Bézier curve.With fewer control points, a lower - degree curve is generated. With more control points, a composite Bézier curve is generated.

###TEST

###QUESTION

SplineDegree -> d specifies that the underlying polynomial basis should have maximal degree d.

Method is a option that determining which algorithm was used.

ControlPoints is a option that determining whether show the control points

SplineClosed is an option that specifies whether spline curves or surfaces should be closed.

CAGDBezierCurve by default represents a composite cubic Bézier curve.

With SplineDegree -> d, CAGDBezierCurve with d + 1 control points yields a simple degree - d Bézier curve.With fewer control points, a lower - degree curve is generated. With more control points, a composite Bézier curve is generated.

TEST

QUESTION

added 415 characters in body
Source Link
xyz
  • 655
  • 4
  • 38
  • 117

UPDATE for 3D CASE

Options[CAGDBezierCurve] = {SplineClosed -> False, 
 SplineDegree -> Automatic, ControlPoints -> False, Method -> Automatic};

CAGDBezierCurve[pts : {{_, _} ..} | {{_, _, _} ..}, opts : OptionsPattern[]] :=
 Module[{sc, sd, cp, Bezier, ptGroupptgroup},
  sc = OptionValue[SplineClosed];
  sd = OptionValue[SplineDegree] /. Automatic -> 3;
  cp = OptionValue[ControlPoints];
  Bezier =
   ToExpression@OptionValue[Method] /. Automatic -> BezierDefinition;
  ptGroupptgroup =
  Partition[pts, sd If[sc+ 1, sd, 1, {}];
  If[Length@First@pts == Partition[Append[pts2, 
 First@pts]  ParametricPlot[
    Evaluate[Bezier[#, sdu] +& 1/@ ptgroup], sd{u, 0, 1},
    Evaluate@
     (Sequence @@
       FilterRules[{opts}], Options[ParametricPlot]]), 
    Partition[pts  Axes -> False, sdPlotRange +-> 1All, 
 sd   Epilog -> If[cp, 1{Green, Line[pts], Red, Point[pts]}, {}]];
]],
  ParametricPlot[ Show[
   Evaluate[ {ParametricPlot3D[
    Bezier[#  Evaluate[Bezier[#, u] & /@ ptGroup]ptgroup], {u, 0, 1},
   Evaluate@
   Evaluate@
 (Sequence @@
     (Sequence FilterRules[@@FilterRules[{opts}, Options[ParametricPlot]]Options[ParametricPlot3D]]), 
      Axes -> False, PlotRange -> AllAll],
    Graphics3D[
   Epilog -> Evaluate@If[cpIf[cp, {Green, Line[pts], Red, Point[pts]}, {]]}]
  ]
 ]

enter image description here

pts1 = {{0, 0, 0}, {1, 1, 1}, {2, -1, 1}, {3, 0, 2}, {5, 3, 4}};

CAGDBezierCurve[pts1, SplineDegree -> 4, ControlPoints -> True]

enter image description here

Options[CAGDBezierCurve] = {SplineClosed -> False, 
 SplineDegree -> Automatic, ControlPoints -> False, Method -> Automatic};

CAGDBezierCurve[pts : {{_, _} ..} | {{_, _, _} ..}, opts : OptionsPattern[]] :=
 Module[{sc, sd, cp, Bezier, ptGroup},
  sc = OptionValue[SplineClosed];
  sd = OptionValue[SplineDegree] /. Automatic -> 3;
  cp = OptionValue[ControlPoints];
  Bezier =
   ToExpression@OptionValue[Method] /. Automatic -> BezierDefinition;
  ptGroup =
    If[sc,
    Partition[Append[pts, First@pts], sd + 1, sd, 1, {}],
    Partition[pts, sd + 1, sd, 1, {}]];

  ParametricPlot[
   Evaluate[
    Bezier[#, u] & /@ ptGroup], {u, 0, 1},
   Evaluate@
    (Sequence @@
      FilterRules[{opts}, Options[ParametricPlot]]), 
   Axes -> False, PlotRange -> All, 
   Epilog -> Evaluate@If[cp, {Green, Line[pts], Red, Point[pts]}, {}]
  ]
 ]

enter image description here

UPDATE for 3D CASE

Options[CAGDBezierCurve] = {SplineClosed -> False, 
 SplineDegree -> Automatic, ControlPoints -> False, Method -> Automatic};

CAGDBezierCurve[pts : {{_, _} ..} | {{_, _, _} ..}, opts : OptionsPattern[]] :=
 Module[{sc, sd, cp, Bezier, ptgroup},
  sc = OptionValue[SplineClosed];
  sd = OptionValue[SplineDegree] /. Automatic -> 3;
  cp = OptionValue[ControlPoints];
  Bezier =
   ToExpression@OptionValue[Method] /. Automatic -> BezierDefinition;
  ptgroup = Partition[pts, sd + 1, sd, 1, {}];
  If[Length@First@pts == 2, 
   ParametricPlot[
    Evaluate[Bezier[#, u] & /@ ptgroup], {u, 0, 1},
    Evaluate@
     (Sequence @@
       FilterRules[{opts}, Options[ParametricPlot]]), 
      Axes -> False, PlotRange -> All, 
    Epilog -> If[cp, {Green, Line[pts], Red, Point[pts]}, {}]],
   Show[
    {ParametricPlot3D[
      Evaluate[Bezier[#, u] & /@ ptgroup], {u, 0, 1},
      Evaluate@
       (Sequence @@FilterRules[{opts}, Options[ParametricPlot3D]]), 
      Axes -> False, PlotRange -> All],
    Graphics3D[
     If[cp, {Green, Line[pts], Red, Point[pts]}]]}]
  ]
]

enter image description here

pts1 = {{0, 0, 0}, {1, 1, 1}, {2, -1, 1}, {3, 0, 2}, {5, 3, 4}};

CAGDBezierCurve[pts1, SplineDegree -> 4, ControlPoints -> True]

enter image description here

Tweeted twitter.com/#!/StackMma/status/633944272350392320
added 24 characters in body
Source Link
xyz
  • 655
  • 4
  • 38
  • 117

Owning to the HoldAll attribute of ParametricPlot, so I must used the Evaluate three times in the ParametricPlot.

In addition, I know the ParametricPlot owns the Evaluated-> True option, so I refactor(remove Evaluate) the part of ParametricPlot as below:

Owning to the HoldAll attribute of ParametricPlot, so I used the Evaluate three times in the ParametricPlot.

In addition, I know the ParametricPlot owns the Evaluated-> True option, so I refactor the part of ParametricPlot as below:

Owning to the HoldAll attribute of ParametricPlot, so I must used the Evaluate three times in the ParametricPlot.

In addition, I know the ParametricPlot owns the Evaluated-> True option, so I refactor(remove Evaluate) the part of ParametricPlot as below:

added 47 characters in body
Source Link
xyz
  • 655
  • 4
  • 38
  • 117
Loading
added 713 characters in body
Source Link
xyz
  • 655
  • 4
  • 38
  • 117
Loading
edited title
Link
xyz
  • 655
  • 4
  • 38
  • 117
Loading
added 253 characters in body
Source Link
xyz
  • 655
  • 4
  • 38
  • 117
Loading
Source Link
xyz
  • 655
  • 4
  • 38
  • 117
Loading