mirror of
https://github.com/csirmaz/openscad-py.git
synced 2025-07-16 14:04:23 +02:00
Add scaling to height maps
This commit is contained in:
parent
a28b85cca5
commit
ebf2a39704
1 changed files with 8 additions and 4 deletions
|
@ -142,13 +142,15 @@ Nonplanar faces will be triangulated by OpenSCAD.</p>
|
|||
return cls(points=point_list, faces=faces, convexity=convexity)
|
||||
|
||||
@classmethod
|
||||
def from_heightmap(cls, heights: List[List[float]], base: float = 0., convexity: int = 10):
|
||||
def from_heightmap(cls, heights: List[List[float]], base: float = 0., step_x: float = 1., step_y: float = 1., convexity: int = 10):
|
||||
"""Construct a polyhedron from a 2D matrix of heights. If the height at [0,0] is Z, it maps
|
||||
to the point (0, 0, Z).
|
||||
|
||||
Arguments:
|
||||
- heights: The 2D matrix of heights
|
||||
- base: The height at which the base will be - in the scale of heights (optional; default 0)
|
||||
- step_x: The X coordinate becomes `step_x * index_x` (default 1)
|
||||
- step_y: The Y coordinate becomes `step_y * index_y` (default 1)
|
||||
- convexity: see OpenSCAD
|
||||
"""
|
||||
rows = len(heights)
|
||||
|
@ -158,8 +160,8 @@ Nonplanar faces will be triangulated by OpenSCAD.</p>
|
|||
bottom_point_map = {}
|
||||
for row_ix, row in enumerate(heights):
|
||||
for col_ix, height in enumerate(row):
|
||||
point = Point([row_ix, col_ix, height])
|
||||
bottom_point = Point([row_ix, col_ix, base])
|
||||
point = Point([row_ix*step_x, col_ix*step_y, height])
|
||||
bottom_point = Point([row_ix*step_x, col_ix*step_y, base])
|
||||
|
||||
point_map[(row_ix, col_ix)] = len(point_list)
|
||||
point_list.append(point)
|
||||
|
@ -291,7 +293,7 @@ Nonplanar faces will be triangulated by OpenSCAD.</p>
|
|||
<h3>Static methods</h3>
|
||||
<dl>
|
||||
<dt id="openscad_py.polyhedron.Polyhedron.from_heightmap"><code class="name flex">
|
||||
<span>def <span class="ident">from_heightmap</span></span>(<span>heights: List[List[float]], base: float = 0.0, convexity: int = 10)</span>
|
||||
<span>def <span class="ident">from_heightmap</span></span>(<span>heights: List[List[float]],<br>base: float = 0.0,<br>step_x: float = 1.0,<br>step_y: float = 1.0,<br>convexity: int = 10)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Construct a polyhedron from a 2D matrix of heights. If the height at [0,0] is Z, it maps
|
||||
|
@ -300,6 +302,8 @@ to the point (0, 0, Z).</p>
|
|||
<ul>
|
||||
<li>heights: The 2D matrix of heights</li>
|
||||
<li>base: The height at which the base will be - in the scale of heights (optional; default 0)</li>
|
||||
<li>step_x: The X coordinate becomes <code>step_x * index_x</code> (default 1)</li>
|
||||
<li>step_y: The Y coordinate becomes <code>step_y * index_y</code> (default 1)</li>
|
||||
<li>convexity: see OpenSCAD</li>
|
||||
</ul></div>
|
||||
</dd>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue