-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update docs /examples page and add those to the demo folder
- Loading branch information
1 parent
6309a80
commit fc0a975
Showing
7 changed files
with
106 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import startinpy | ||
import numpy as np | ||
|
||
#-- generate 100 points randomly in the plane | ||
rng = np.random.default_rng(seed=42) | ||
pts = rng.random((100, 3)) | ||
dt = startinpy.DT() | ||
dt.insert(pts, insertionstrategy="AsIs") | ||
dt.write_geojson("myfile.geojson") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import startinpy | ||
import meshio | ||
import laspy | ||
import numpy as np | ||
|
||
las = laspy.read("../data/small.laz") | ||
pts = np.vstack((las.x, las.y, las.z)).transpose() | ||
dt = startinpy.DT() | ||
dt.insert(pts) | ||
vs = dt.points | ||
vs[0] = vs[1] #-- to ensure that infinite vertex is not blocking the viz | ||
cells = [("triangle", dt.triangles)] | ||
meshio.write_points_cells("mydt.vtu", vs, cells) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import startinpy | ||
import numpy as np | ||
|
||
#-- generate 100 points randomly in the plane | ||
rng = np.random.default_rng(seed=42) | ||
pts = rng.random((100, 3)) | ||
#-- scale to [0, 100] | ||
pts = pts * 100 | ||
t = startinpy.DT() | ||
t.insert(pts) | ||
pts = t.points | ||
trs = t.triangles | ||
#-- plot | ||
import matplotlib.pyplot as plt | ||
plt.triplot(pts[:,0], pts[:,1], trs) | ||
#-- the vertex "0" shouldn't be plotted, so start at 1 | ||
plt.plot(pts[1:,0], pts[1:,1], 'o') | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import startinpy | ||
import numpy as np | ||
import polyscope as ps | ||
import laspy | ||
|
||
las = laspy.read("../data/small.laz") | ||
pts = np.vstack((las.x, las.y, las.z)).transpose() | ||
pts = pts[::10] #-- thinning to speed up, put ::10 to keep 1/10 of the points | ||
dt = startinpy.DT() | ||
dt.insert(pts) | ||
|
||
pts = dt.points | ||
pts[0] = pts[1] #-- first vertex has inf and could mess things | ||
trs = dt.triangles | ||
|
||
ps.init() | ||
ps.set_program_name("mydt") | ||
ps.set_up_dir("z_up") | ||
ps.set_ground_plane_mode("shadow_only") | ||
ps.set_ground_plane_height_factor(0.01, is_relative=True) | ||
ps.set_autocenter_structures(True) | ||
ps.set_autoscale_structures(True) | ||
pc = ps.register_point_cloud("mypoints", pts[1:], radius=0.0015, point_render_mode='sphere') | ||
ps_mesh = ps.register_surface_mesh("mysurface", pts, trs) | ||
ps_mesh.reset_transform() | ||
pc.reset_transform() | ||
ps.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import startinpy | ||
import rasterio | ||
import random | ||
|
||
d = rasterio.open('../data/dem_01.tif') | ||
band1 = d.read(1) | ||
t = d.transform | ||
pts = [] | ||
for i in range(band1.shape[0]): | ||
for j in range(band1.shape[1]): | ||
x = t[2] + (j * t[0]) + (t[0] / 2) | ||
y = t[5] + (i * t[4]) + (t[4] / 2) | ||
z = band1[i][j] | ||
if (z != d.nodatavals) and (random.randint(0, 100) == 5): | ||
pts.append([x, y, z]) | ||
dt = startinpy.DT() | ||
dt.insert(pts, insertionstrategy="BBox") | ||
#-- exaggerate the elevation by a factor 2.0 | ||
dt.vertical_exaggeration(2.0) | ||
dt.write_ply("mydt.ply") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import startinpy | ||
import numpy as np | ||
import laspy | ||
|
||
las = laspy.read("../data/small.laz") | ||
pts = np.vstack((las.x, las.y, las.z)).transpose() | ||
pts = pts[::1] #-- thinning to speed up, put ::10 to keep 1/10 of the points | ||
dt = startinpy.DT() | ||
dt.insert(pts) | ||
print("number vertices:", dt.number_of_vertices()) | ||
# -- number vertices: 39231 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters