Skip to content

lhalve/np2stl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

np2stl

Create 3D STL files from numpy data

Installation:

  1. Clone the repository
git clone git@github.com:lhalve/np2stl.git
  1. Install dependencies
cd np2stl
pip3 install -r requirements.txt
  1. Add this repository to your PYTHONPATH environment variable
cd np2stl
export PYTHONPATH="${PYTHONPATH}:$PWD"

Usage:

Example usage for a numpy 2-dimensional histogram:

import numpy as np
from np2stl import stl_builder

# create random numbers according to a 2d Gaussian distribution
rand = np.random.multivariate_normal([4, 7], np.diag([2, 3]), size=1000000)
# create a 2-dimensional histogram of these data
hist = np.histogram2d(rand[:, 0], rand[:, 1], bins=100)

# intialize the 3d object
builder = stl_builder.STLBuilder()
# feed the histogram to the 3d object
builder.from_numpy_2dhist(*hist)
# save the 3d object to a stl
builder.save("gauss_2d.stl")

Output:

You can view .stl files with any 3d viewer. The example above creates an stl file similar to this: Screenshot of a view of a .stl file of a two-dimension Gaussian distribution.

About

Create 3D STL files from numpy data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages