Skip to content

Commit

Permalink
docs: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanchristopheruel committed Mar 17, 2024
1 parent 579b6ac commit dc056d9
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,36 @@ quad = np.array([
])

# Serialize the triangles to a file
success = openstl.write("output.stl", quad, openstl.format.binary) # Or openstl.format.ascii (slower but human readable)
success = openstl.write("quad.stl", quad, openstl.format.binary) # Or openstl.format.ascii (slower but human readable)

if not success:
raise Exception("Error: Failed to write to the specified file.")

# Deserialize triangles from a file
deserialized_quad = openstl.read("output.stl")
deserialized_quad = openstl.read("quad.stl")

# Print the deserialized triangles
print("Deserialized Triangles:", deserialized_quad)
```
### Rotate and translate a mesh
```python
import openstl
import numpy as np

quad = openstl.read("quad.stl")

# Rotation
rotation_matrix = np.array([
[0,-1, 0],
[1, 0, 0],
[0, 0, 1]
])
rotated_quad = np.matmul(rotation_matrix, quad.reshape(-1,3).T).T.reshape()

# Translation
translation_vector = np.array([1,1,1])
quad[:,1:4,:] += translation_vector # Avoid translating normals
```

# C++ Usage
### Read STL from file
Expand Down

0 comments on commit dc056d9

Please sign in to comment.