Skip to content

Commit

Permalink
Update split and decompose examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Onur R. Bingol committed Feb 9, 2018
1 parent 6bdae2a commit e58f639
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 38 deletions.
9 changes: 3 additions & 6 deletions curve2d/ex_curve01_decompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import os
from geomdl import BSpline
from geomdl import utilities
from geomdl import Multi

# Try to load the visualization module
try:
Expand Down Expand Up @@ -38,14 +37,12 @@
bezier = curve.decompose()

# Plot the curves using the curve container
curves = Multi.MultiCurve()
curves.delta = 0.01
curves.add_list(bezier)
bezier.delta = 0.01

if render_curve:
vis_comp = VisMPL.VisCurve2D()
curves.vis = vis_comp
curves.render()
bezier.vis = vis_comp
bezier.render()

# Good to have something here to put a breakpoint
pass
11 changes: 4 additions & 7 deletions curve2d/ex_curve01_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import os
from geomdl import BSpline
from geomdl import utilities
from geomdl import Multi

# Try to load the visualization module
try:
Expand All @@ -35,18 +34,16 @@
curve.knotvector = utilities.generate_knot_vector(curve.degree, len(curve.ctrlpts))

# Split the curve
curve1, curve2 = curve.split(0.6)
curves = curve.split(0.6)

# Move the 1st curve a little bit far away from the 2nd curve
c2tan = curve2.tangent(0.0, normalize=True)
c2tan = curves[1].tangent(0.0, normalize=True)
c2tanvec = [-3 * p for p in c2tan[1]]
curve1.translate(c2tanvec)
curves[0].translate(c2tanvec)

# Plot the curves using the curve container
curves = Multi.MultiCurve()
curves.delta = 0.01
curves.add(curve1)
curves.add(curve2)

if render_curve:
vis_comp = VisMPL.VisCurve2D()
curves.vis = vis_comp
Expand Down
9 changes: 3 additions & 6 deletions curve2d/ex_curve02_decompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import os
from geomdl import BSpline
from geomdl import utilities
from geomdl import Multi

# Try to load the visualization module
try:
Expand Down Expand Up @@ -47,14 +46,12 @@
bezier[2].translate(c2tanvec2)

# Plot the curves using the curve container
curves = Multi.MultiCurve()
curves.delta = 0.01
curves.add_list(bezier)
bezier.delta = 0.01

if render_curve:
vis_comp = VisMPL.VisCurve2D()
curves.vis = vis_comp
curves.render()
bezier.vis = vis_comp
bezier.render()

# Good to have something here to put a breakpoint
pass
9 changes: 3 additions & 6 deletions curve2d/ex_curve04_decompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""
import os
from geomdl import NURBS
from geomdl import Multi

# Try to load the visualization module
try:
Expand Down Expand Up @@ -36,15 +35,13 @@
bezier = curve.decompose()

# Plot the curves using the curve container
curves = Multi.MultiCurve()
curves.delta = 0.01
curves.add_list(bezier)
bezier.delta = 0.01

if render_curve:
vis_comp = VisMPL.VisCurve2D()
vis_comp.figure_size([8, 8])
curves.vis = vis_comp
curves.render()
bezier.vis = vis_comp
bezier.render()

# Good to have something here to put a breakpoint
pass
10 changes: 3 additions & 7 deletions curve3d/ex_curve3d01_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import os
from geomdl import BSpline
from geomdl import utilities
from geomdl import Multi

# Try to load the visualization module
try:
Expand All @@ -35,18 +34,15 @@
curve.knotvector = utilities.generate_knot_vector(curve.degree, len(curve.ctrlpts))

# Split the curve
curve1, curve2 = curve.split(0.3)
curves = curve.split(0.3)

# Move the 1st curve a little bit far away from the 2nd curve
c2tan = curve2.tangent(0.0, normalize=True)
c2tan = curves[1].tangent(0.0, normalize=True)
c2tanvec = [-1 * p for p in c2tan[1]]
curve1.translate(c2tanvec)
curves[0].translate(c2tanvec)

# Plot the curves using the curve container
curves = Multi.MultiCurve()
curves.delta = 0.01
curves.add(curve1)
curves.add(curve2)
if render_curve:
vis_comp = VisMPL.VisCurve3D()
curves.vis = vis_comp
Expand Down
9 changes: 3 additions & 6 deletions shapes/ex_circle2d_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Developed by Onur Rauf Bingol (c) 2018
"""
from geomdl.shapes import curve2d
from geomdl import Multi

# Try to load the visualization module
try:
Expand All @@ -31,16 +30,14 @@
bezier_segments = circle.decompose()

# Prepare Bezier segments for plotting
curves = Multi.MultiCurve()
curves.add_list(bezier_segments)
curves.delta = 0.01
bezier_segments.delta = 0.01

# Render the Bezier curve segments and their control points polygons
if render:
vis_comp = VisMPL.VisCurve2D(plot_ctrlpts=True)
vis_comp.figure_size([9, 8])
curves.vis = vis_comp
curves.render()
bezier_segments.vis = vis_comp
bezier_segments.render()

# Good to have something here to put a breakpoint
pass

0 comments on commit e58f639

Please sign in to comment.