Skip to content

Commit a983f42

Browse files
committed
docstrings
1 parent 5a8f46d commit a983f42

File tree

5 files changed

+45
-30
lines changed

5 files changed

+45
-30
lines changed

src/compas/geometry/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353
.. autosummary::
5454
:toctree: generated/
5555
56-
aabb
57-
aabb_xy
58-
obb_numpy
59-
obb_xy_numpy
56+
bounding_box
57+
bounding_box_xy
58+
oriented_bounding_box_numpy
59+
oriented_bounding_box_xy_numpy
6060
6161
**fitting**
6262

src/compas/geometry/algorithms/bbox.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111

1212
__all__ = [
13-
'aabb',
14-
'aabb_xy',
15-
'obb_numpy',
16-
'obb_xy_numpy',
13+
'bounding_box',
14+
'bounding_box_xy',
15+
'oriented_bounding_box_numpy',
16+
'oriented_bounding_box_xy_numpy',
1717
]
1818

1919

20-
def aabb(points):
20+
def bounding_box(points):
2121
"""Computes the axis-aligned minimum bounding box of a list of points.
2222
2323
Parameters
@@ -54,7 +54,7 @@ def aabb(points):
5454
(min_x, max_y, max_z)]
5555

5656

57-
def aabb_xy(points):
57+
def bounding_box_xy(points):
5858
"""Compute the axis-aligned minimum bounding box of a list of points in the XY-plane.
5959
6060
Note
@@ -89,7 +89,7 @@ def aabb_xy(points):
8989
(min_x, max_y, 0.0)]
9090

9191

92-
def obb_numpy(points):
92+
def oriented_bounding_box_numpy(points):
9393
"""Compute the oriented minimum bounding box of a set of points in 3D space.
9494
9595
Note
@@ -122,7 +122,7 @@ def obb_numpy(points):
122122
from compas.plotters import create_axes_3d
123123
from compas.geometry import rotation_matrix
124124
from compas.geometry import transform
125-
from compas.geometry import obb_numpy
125+
from compas.geometry import oriented_bounding_box_numpy
126126
127127
clouds = []
128128
@@ -167,7 +167,7 @@ def obb_numpy(points):
167167
bounds.plot(axes)
168168
169169
for cloud in clouds:
170-
bbox = obb_numpy(cloud)
170+
bbox = oriented_bounding_box_numpy(cloud)
171171
172172
Cloud3D(cloud).plot(axes)
173173
Box(bbox[1]).plot(axes)
@@ -224,7 +224,7 @@ def obb_numpy(points):
224224
return hull, bbox, volume
225225

226226

227-
def obb_xy_numpy(points):
227+
def oriented_bounding_box_xy_numpy(points):
228228
"""Compute the oriented minimum bounding box of set of points in the XY plane.
229229
230230
Note

src/compas/numerical/algorithms/drx_numpy.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,28 @@ def drx_numpy(network, factor=1.0, tol=0.1, steps=10000, refresh=0, update=False
6060
from compas.numerical import drx_numpy
6161
from compas.utilities import i_to_rgb
6262
63-
network = Network.from_obj(compas.get('lines.obj'))
64-
network.update_default_vertex_attributes({'is_fixed': False, 'P': [1, 1, 0]})
65-
network.update_default_edge_attributes({'E': 10, 'A': 1, 'ct': 't'})
66-
network.set_vertices_attributes(network.leaves(), {'B': [0, 0, 0], 'is_fixed': True})
63+
from numpy import linspace
6764
68-
drx_numpy(network=network, tol=0.001, refresh=5, update=True)
65+
L0 = 1
66+
L = 1.5
67+
n = 40
68+
EI = 0.2
69+
pins = [0, 5, 20, n - 5]
6970
70-
plotter = NetworkPlotter(network)
71+
# Network
72+
73+
vertices = [[i, i, 0] for i in list(linspace(0, L0, n))]
74+
edges = [[i, i + 1] for i in range(n - 1)]
75+
76+
network = Network.from_vertices_and_edges(vertices=vertices, edges=edges)
77+
network.update_default_vertex_attributes({'is_fixed': False, 'P': [1, -2, 0], 'EIx': EI, 'EIy': EI})
78+
network.update_default_edge_attributes({'E': 50, 'A': 1, 'l0': L / n})
79+
network.set_vertices_attributes(pins, {'B': [0, 0, 0], 'is_fixed': True})
80+
network.beams = {'beam': {'nodes': list(range(n))}}
81+
82+
# Plotter
83+
84+
plotter = NetworkPlotter(network, figsize=(10, 7))
7185
lines = []
7286
for u, v in network.edges():
7387
lines.append({
@@ -76,13 +90,12 @@ def drx_numpy(network, factor=1.0, tol=0.1, steps=10000, refresh=0, update=False
7690
'color': '#cccccc',
7791
'width': 1.0})
7892
plotter.draw_lines(lines)
79-
plotter.draw_vertices(facecolor={key: '#ff0000' for key in network.vertices_where({'is_fixed': True})})
93+
plotter.draw_vertices(radius=0.005, facecolor={key: '#ff0000' for key in network.vertices_where({'is_fixed': True})})
94+
plotter.draw_edges()
8095
81-
fmax = max(network.get_edges_attribute('f'))
96+
# Solver
8297
83-
plotter.draw_edges(
84-
color={(u, v): i_to_rgb(attr['f'] / fmax) for u, v, attr in network.edges(True)},
85-
width={(u, v): 10 * attr['f'] / fmax for u, v, attr in network.edges(True)})
98+
drx_numpy(network=network, tol=0.01, refresh=10, factor=30, update=True)
8699
87100
plotter.show()
88101

src/compas/topology/traversal.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,14 @@ def depth_first_tree(adjacency, root):
111111
112112
Example
113113
-------
114-
.. code-block:: python
114+
.. plot::
115+
:include-source:
115116
116117
import compas
117118
from compas.datastructures import Mesh
118119
from compas.plotters import MeshPlotter
119120
from compas.topology import depth_first_tree
121+
from compas.utilities import pairwise
120122
121123
mesh = Mesh.from_obj(compas.get('faces.obj'))
122124
@@ -145,7 +147,7 @@ def depth_first_tree(adjacency, root):
145147
146148
plotter = MeshPlotter(mesh, figsize=(10, 7))
147149
148-
plotter.draw_vertices(text='key', facecolor={key: '#ff0000' for key in (root, )}, radius=0.2)
150+
plotter.draw_vertices(text='key', facecolor={root: '#ff0000'}, radius=0.2)
149151
plotter.draw_edges(color=edgecolor, width=edgewidth)
150152
151153
plotter.show()

src/compas/topology/triangulation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from compas.geometry import centroid_points
77
from compas.geometry import distance_point_point
88
from compas.geometry import add_vectors
9-
from compas.geometry import aabb
9+
from compas.geometry import bounding_box
1010

1111
from compas.geometry import is_point_in_polygon_xy
1212
from compas.geometry import is_point_in_triangle_xy
@@ -82,7 +82,7 @@ def delaunay_from_points(points, boundary=None, holes=None, tiny=1e-12):
8282

8383
def super_triangle(coords):
8484
centpt = centroid_points(coords)
85-
bbpts = aabb(coords)
85+
bbpts = bounding_box(coords)
8686
dis = distance_point_point(bbpts[0], bbpts[2])
8787
dis = dis * 300
8888
v1 = (0 * dis, 2 * dis, 0)
@@ -389,7 +389,7 @@ def trimesh_remesh(mesh,
389389
390390
References
391391
----------
392-
* Botsch, M. & Kobbelt, L., 2004. A remeshing approach to multiresolution modeling.
392+
* Botsch, M. & Koriented_bounding_boxelt, L., 2004. A remeshing approach to multiresolution modeling.
393393
Proceedings of the 2004 Eurographics/ACM SIGGRAPH symposium on Geometry processing - SGP '04, p.185.
394394
Available at: http://portal.acm.org/citation.cfm?doid=1057432.1057457
395395

0 commit comments

Comments
 (0)