Skip to content

Commit 192c10a

Browse files
committed
add support for circle, ellipse, vector, plane, curve, surface primitives
- converters use angular resolution for circles/ellipses - vector rendered as arrow with cone head - plane shown as grid - curve/surface discretization (requires nurbs plugin for creation)
1 parent ac86bb5 commit 192c10a

File tree

9 files changed

+495
-15
lines changed

9 files changed

+495
-15
lines changed

notebooks/20_geometry.ipynb

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 2,
5+
"execution_count": 1,
66
"metadata": {},
77
"outputs": [],
88
"source": [
99
"from compas.colors import Color\n",
10+
"from compas.geometry import Circle\n",
11+
"from compas.geometry import Ellipse\n",
12+
"from compas.geometry import Frame\n",
1013
"from compas.geometry import Line\n",
14+
"from compas.geometry import Plane\n",
1115
"from compas.geometry import Point\n",
1216
"from compas.geometry import Pointcloud\n",
1317
"from compas.geometry import Polyline\n",
14-
"from compas.geometry import Frame \n",
18+
"from compas.geometry import Vector\n",
1519
"from compas_notebook.viewer import Viewer"
1620
]
1721
},
1822
{
1923
"cell_type": "code",
20-
"execution_count": 3,
24+
"execution_count": 2,
2125
"metadata": {},
2226
"outputs": [],
2327
"source": [
@@ -39,13 +43,13 @@
3943
},
4044
{
4145
"cell_type": "code",
42-
"execution_count": 4,
46+
"execution_count": 3,
4347
"metadata": {},
4448
"outputs": [
4549
{
4650
"data": {
4751
"application/vnd.jupyter.widget-view+json": {
48-
"model_id": "60cefc1deea3458c9e1a390cdd0ea3ba",
52+
"model_id": "0498e1e0a2e3459480997d957fbfc9da",
4953
"version_major": 2,
5054
"version_minor": 0
5155
},
@@ -68,11 +72,78 @@
6872
"\n",
6973
"viewer.show()"
7074
]
75+
},
76+
{
77+
"cell_type": "code",
78+
"execution_count": null,
79+
"metadata": {},
80+
"outputs": [],
81+
"source": []
82+
},
83+
{
84+
"cell_type": "markdown",
85+
"metadata": {},
86+
"source": [
87+
"# New Primitives\n",
88+
"\n",
89+
"Demonstration of recently added primitive support: Circle, Ellipse, Vector, and Plane."
90+
]
91+
},
92+
{
93+
"cell_type": "code",
94+
"execution_count": 4,
95+
"metadata": {},
96+
"outputs": [],
97+
"source": [
98+
"# Create new primitives\n",
99+
"circle = Circle(radius=1.5, frame=Frame([2, 0, 0], [0, 1, 0], [0, 0, 1]))\n",
100+
"ellipse = Ellipse(major=2.0, minor=1.0, frame=Frame([5, 0, 0], [0, 1, 0], [0, 0, 1]))\n",
101+
"vector = Vector(1, 1, 2)\n",
102+
"plane = Plane([0, 0, -1], [0, 0, 1])"
103+
]
104+
},
105+
{
106+
"cell_type": "code",
107+
"execution_count": 5,
108+
"metadata": {},
109+
"outputs": [
110+
{
111+
"data": {
112+
"application/vnd.jupyter.widget-view+json": {
113+
"model_id": "3cac0c93ba69483fb0534923124dbe15",
114+
"version_major": 2,
115+
"version_minor": 0
116+
},
117+
"text/plain": [
118+
"VBox(children=(HBox(children=(Button(icon='search-plus', layout=Layout(height='32px', width='48px'), style=But…"
119+
]
120+
},
121+
"metadata": {},
122+
"output_type": "display_data"
123+
}
124+
],
125+
"source": [
126+
"viewer2 = Viewer()\n",
127+
"\n",
128+
"viewer2.scene.add(circle, color=Color.red())\n",
129+
"viewer2.scene.add(ellipse, color=Color.green())\n",
130+
"viewer2.scene.add(vector)\n",
131+
"viewer2.scene.add(plane)\n",
132+
"\n",
133+
"viewer2.show()"
134+
]
135+
},
136+
{
137+
"cell_type": "code",
138+
"execution_count": null,
139+
"metadata": {},
140+
"outputs": [],
141+
"source": []
71142
}
72143
],
73144
"metadata": {
74145
"kernelspec": {
75-
"display_name": "compas_opzuid",
146+
"display_name": "Python 3 (ipykernel)",
76147
"language": "python",
77148
"name": "python3"
78149
},
@@ -90,5 +161,5 @@
90161
}
91162
},
92163
"nbformat": 4,
93-
"nbformat_minor": 2
164+
"nbformat_minor": 4
94165
}

0 commit comments

Comments
 (0)