Skip to content

Commit

Permalink
docs: add scaling example
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanchristopheruel committed Mar 18, 2024
1 parent 27abc0f commit fd40e25
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,28 @@ deserialized_quad = openstl.read("quad.stl")
# Print the deserialized triangles
print("Deserialized Triangles:", deserialized_quad)
```
### Rotate and translate a mesh
### Rotate, translate and scale a mesh
```python
import openstl
import numpy as np

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

# Rotation
# Rotating
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(-1,4,3)

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

# Scaling
scale = 1000.0
quad[:,1:4,:] *= scale # Avoid scaling normals
```

# C++ Usage
Expand Down

0 comments on commit fd40e25

Please sign in to comment.