Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Project Work
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabian Del Villar
Project Work
Commits
77ecf9b5
Commit
77ecf9b5
authored
1 year ago
by
Fabian
Browse files
Options
Downloads
Patches
Plain Diff
Create test3.py
parent
ddef1e1e
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test3.py
+93
-0
93 additions, 0 deletions
test3.py
with
93 additions
and
0 deletions
test3.py
0 → 100644
+
93
−
0
View file @
77ecf9b5
import
pythreejs
as
three
from
IPython.display
import
display
def
create_rectangular_prism
():
# Prompt for the dimensions of the rectangular prism
length
=
float
(
input
(
"
Enter the length of the prism:
"
))
width
=
float
(
input
(
"
Enter the width of the prism:
"
))
height
=
float
(
input
(
"
Enter the height of the prism:
"
))
# Create the STL code for the rectangular prism
stl_code
=
f
'
solid prism
\n
'
# Front face
stl_code
+=
f
'
facet normal 0 0 -1
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex 0 0 0
\n
'
stl_code
+=
f
'
vertex
{
length
}
0 0
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
0
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
# Back face
stl_code
+=
f
'
facet normal 0 0 1
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex 0
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
vertex
{
length
}
0
{
height
}
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
# Right face
stl_code
+=
f
'
facet normal 1 0 0
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex
{
length
}
0 0
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
0
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
# Left face
stl_code
+=
f
'
facet normal -1 0 0
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex 0
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
vertex 0 0
{
height
}
\n
'
stl_code
+=
f
'
vertex 0 0 0
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
# Top face
stl_code
+=
f
'
facet normal 0 1 0
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex 0
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
0
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
# Bottom face
stl_code
+=
f
'
facet normal 0 -1 0
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex 0 0 0
\n
'
stl_code
+=
f
'
vertex
{
length
}
0 0
\n
'
stl_code
+=
f
'
vertex
{
length
}
0
{
height
}
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
stl_code
+=
f
'
endsolid prism
\n
'
# Write the STL code to a file
with
open
(
'
prism.stl
'
,
'
w
'
)
as
file
:
file
.
write
(
stl_code
)
# Create the rectangular prism geometry
geometry
=
three
.
BoxGeometry
(
length
=
length
,
width
=
width
,
height
=
height
)
# Create the material and mesh
material
=
three
.
MeshBasicMaterial
(
color
=
'
lightblue
'
,
side
=
'
DoubleSide
'
)
mesh
=
three
.
Mesh
(
geometry
=
geometry
,
material
=
material
)
# Create the scene and add the mesh
scene
=
three
.
Scene
()
scene
.
add
(
mesh
)
# Create the camera and renderer
camera
=
three
.
PerspectiveCamera
(
position
=
[
10
,
10
,
10
],
aspect
=
1
)
renderer
=
three
.
Renderer
(
camera
=
camera
,
scene
=
scene
,
controls
=
[
three
.
OrbitControls
(
controlling
=
camera
)])
# Render the scene
display
(
renderer
)
# Call the function to create the rectangular prism and generate the image
create_rectangular_prism
()
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment