Skip to content

Commit 6bdae2a

Browse files
author
Onur R. Bingol
committed
Add a new 2D circle example
1 parent aedf558 commit 6bdae2a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

shapes/ex_circle2d_2.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
Examples for the NURBS-Python Package
6+
Released under MIT License
7+
Developed by Onur Rauf Bingol (c) 2018
8+
"""
9+
from geomdl.shapes import curve2d
10+
from geomdl import Multi
11+
12+
# Try to load the visualization module
13+
try:
14+
render = True
15+
from geomdl.visualization import VisMPL
16+
except ImportError:
17+
render = False
18+
19+
# Generate a NURBS full circle from 7 control points
20+
circle = curve2d.full_circle2(radius=5.0)
21+
circle.delta = 0.01
22+
23+
# Render the circle and the control points polygon
24+
if render:
25+
vis_comp = VisMPL.VisCurve2D(plot_ctrlpts=True)
26+
vis_comp.figure_size([9, 8])
27+
circle.vis = vis_comp
28+
circle.render()
29+
30+
# Decompose the circle into Bezier curve segments
31+
bezier_segments = circle.decompose()
32+
33+
# Prepare Bezier segments for plotting
34+
curves = Multi.MultiCurve()
35+
curves.add_list(bezier_segments)
36+
curves.delta = 0.01
37+
38+
# Render the Bezier curve segments and their control points polygons
39+
if render:
40+
vis_comp = VisMPL.VisCurve2D(plot_ctrlpts=True)
41+
vis_comp.figure_size([9, 8])
42+
curves.vis = vis_comp
43+
curves.render()
44+
45+
# Good to have something here to put a breakpoint
46+
pass

0 commit comments

Comments
 (0)