Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OrigamiSimulator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
7eb9dba6
Commit
7eb9dba6
authored
Oct 07, 2017
by
amandaghassaei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc
parent
d0bdd92b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
241 additions
and
1 deletion
+241
-1
CreasePatternScripts/SquareTwist/SquareTwist.pde
CreasePatternScripts/SquareTwist/SquareTwist.pde
+166
-0
CreasePatternScripts/TriTesselation/TriTesselation.pde
CreasePatternScripts/TriTesselation/TriTesselation.pde
+74
-0
README.md
README.md
+1
-1
No files found.
CreasePatternScripts/SquareTwist/SquareTwist.pde
0 → 100755
View file @
7eb9dba6
import
processing
.
pdf
.
*
;
boolean
mountValleyColors
=
true
;
boolean
dashedCreaseLines
=
true
;
float
angle
=
PI
/
3
;
// PI/2 > angle > 0
float
edgeLength
=
72
;
//1in and 72dpi
float
diagLength
=
2
*
edgeLength
/
sqrt
(
2
);
void
setup
()
{
size
(
400
,
400
);
//tesselation
beginRecord
(
PDF
,
"squaretwisttesselation.pdf"
);
background
(
255
);
makeUnitCell
(
200
,
200
);
endRecord
();
//single twist
beginRecord
(
PDF
,
"squaretwist.pdf"
);
background
(
255
);
makeSingleUnitCell
(
width
/
2
,
height
/
2
);
endRecord
();
//many single twists
size
(
700
,
700
);
beginRecord
(
PDF
,
"squaretwistManyAngles.pdf"
);
background
(
255
);
for
(
int
i
=
0
;
i
<
3
;
i
++
){
for
(
int
j
=
0
;
j
<
3
;
j
++
){
float
index
=
i
*
3
+
j
;
angle
=
map
(
index
,
0
,
8
,
PI
/
6
,
2
*
PI
/
6
);
makeSingleUnitCell
(
j
*
width
/
3
+
width
/
6
,
i
*
height
/
3
+
height
/
6
);
}
}
endRecord
();
// // Exit the program
println
(
"Finished."
);
exit
();
}
void
makeSingleUnitCell
(
float
x
,
float
y
){
makeUnitCell
(
x
,
y
,
true
,
true
,
true
,
true
,
true
);
}
void
makeUnitCell
(
float
x
,
float
y
){
makeUnitCell
(
x
,
y
,
false
,
false
,
false
,
false
,
false
);
}
void
makeUnitCell
(
float
x
,
float
y
,
boolean
allBounds
,
boolean
leftBounds
,
boolean
topBounds
,
boolean
bottomBounds
,
boolean
rightBounds
){
pushMatrix
();
translate
(
x
,
y
);
rotate
(
-
angle
/
2
);
setMountainColor
();
//top
float
square1X
=
diagLength
/
2
*
sin
(
angle
-
PI
/
4
);
float
square1Y
=
-
diagLength
/
2
*
cos
(
angle
-
PI
/
4
);
//right
float
square2X
=
diagLength
/
2
*
sin
(
angle
+
PI
/
4
);
float
square2Y
=
-
diagLength
/
2
*
cos
(
angle
+
PI
/
4
);
drawCrease
(
square1X
,
square1Y
,
square1X
,
square1Y
-
edgeLength
);
drawCrease
(
-
square1X
,
-
square1Y
,
-
square1X
,
-
square1Y
+
edgeLength
);
drawCrease
(
square2X
,
square2Y
,
square2X
+
edgeLength
,
square2Y
);
drawCrease
(
-
square2X
,
-
square2Y
,
-
square2X
-
edgeLength
,
-
square2Y
);
//inner square
drawCrease
(
square1X
,
square1Y
,
square2X
,
square2Y
);
drawCrease
(
square1X
,
square1Y
,
-
square2X
,
-
square2Y
);
drawCrease
(
-
square1X
,
-
square1Y
,
square2X
,
square2Y
);
drawCrease
(
-
square1X
,
-
square1Y
,
-
square2X
,
-
square2Y
);
//bounds
if
(
allBounds
)
setCutColor
();
if
(
leftBounds
){
//left
line
(
square1X
-
edgeLength
,
square1Y
-
edgeLength
,
square1X
-
edgeLength
,
square1Y
);
line
(
square1X
-
edgeLength
,
square1Y
,
-
square2X
-
edgeLength
,
-
square2Y
);
line
(
-
square2X
-
edgeLength
,
-
square2Y
,
-
square2X
-
edgeLength
,
-
square2Y
+
edgeLength
);
}
if
(
topBounds
){
//top
line
(
square1X
,
square1Y
-
edgeLength
,
square1X
-
edgeLength
,
square1Y
-
edgeLength
);
line
(
square1X
,
square1Y
-
edgeLength
,
square2X
,
square2Y
-
edgeLength
);
line
(
square2X
,
square2Y
-
edgeLength
,
square2X
+
edgeLength
,
square2Y
-
edgeLength
);
}
if
(
rightBounds
){
//right
line
(
square2X
+
edgeLength
,
square2Y
-
edgeLength
,
square2X
+
edgeLength
,
square2Y
);
line
(
square2X
+
edgeLength
,
square2Y
,
-
square1X
+
edgeLength
,
-
square1Y
);
line
(
-
square1X
+
edgeLength
,
-
square1Y
,
-
square1X
+
edgeLength
,
-
square1Y
+
edgeLength
);
}
if
(
bottomBounds
){
//bottom
line
(
-
square1X
+
edgeLength
,
-
square1Y
+
edgeLength
,
-
square1X
,
-
square1Y
+
edgeLength
);
line
(
-
square1X
,
-
square1Y
+
edgeLength
,
-
square2X
,
-
square2Y
+
edgeLength
);
line
(
-
square2X
,
-
square2Y
+
edgeLength
,
-
square2X
-
edgeLength
,
-
square2Y
+
edgeLength
);
}
setValleyColor
();
drawCrease
(
square1X
,
square1Y
,
square1X
-
edgeLength
,
square1Y
);
drawCrease
(
-
square1X
,
-
square1Y
,
-
square1X
+
edgeLength
,
-
square1Y
);
drawCrease
(
square2X
,
square2Y
,
square2X
,
square2Y
-
edgeLength
);
drawCrease
(
-
square2X
,
-
square2Y
,
-
square2X
,
-
square2Y
+
edgeLength
);
popMatrix
();
}
void
setMountainColor
(){
if
(
mountValleyColors
){
stroke
(
0
,
0
,
255
);
//blue
}
else
{
setCreaseColor
();
}
}
void
setValleyColor
(){
if
(
mountValleyColors
){
stroke
(
255
,
0
,
0
);
//red
}
else
{
setCreaseColor
();
}
}
void
setCutColor
(){
stroke
(
0
);
//black
}
void
setCreaseColor
(){
stroke
(
255
,
0
,
0
);
//red
}
void
drawCrease
(
float
x1
,
float
y1
,
float
x2
,
float
y2
){
if
(
dashedCreaseLines
){
dashedLine
(
x1
,
y1
,
x2
,
y2
,
6
,
6
);
}
else
{
line
(
x1
,
y1
,
x2
,
y2
);
}
}
void
dashedLine
(
float
x1
,
float
y1
,
float
x2
,
float
y2
,
float
dashLength
,
float
spaceLength
){
pushMatrix
();
translate
(
x1
,
y1
);
rotate
(
atan2
(
y2
-
y1
,
x2
-
x1
));
float
lineLength
=
sqrt
((
y2
-
y1
)
*
(
y2
-
y1
)
+
(
x2
-
x1
)
*
(
x2
-
x1
));
float
partialDash
=
lineLength
/
(
dashLength
+
spaceLength
)
-
floor
(
lineLength
/
(
dashLength
+
spaceLength
));
for
(
float
i
=
(
partialDash
+
spaceLength
)
/
2
;
i
<
lineLength
;
i
+=
dashLength
+
spaceLength
){
line
(
i
,
0
,
i
+
dashLength
,
0
);
}
popMatrix
();
}
CreasePatternScripts/TriTesselation/TriTesselation.pde
0 → 100755
View file @
7eb9dba6
import
processing
.
pdf
.
*
;
float
triangleHeight
=
40
;
//40px/72dpi = ~0.55in tall
boolean
dashedCreaseLines
=
true
;
void
setup
()
{
//20in*72dpi= 1440px
size
(
1440
,
1440
,
PDF
,
"tritesselation.pdf"
);
background
(
255
);
//horizontal lines
for
(
float
i
=
triangleHeight
;
i
<
height
;
i
+=
triangleHeight
){
drawCrease
(
0
,
i
,
width
,
i
);
}
// \\\\\\ lines
for
(
float
i
=-
height
/
sqrt
(
3
);
i
<
width
;
i
+=
2
*
triangleHeight
/
sqrt
(
3
)){
float
xPos
=
i
+
height
/
sqrt
(
3
);
if
(
xPos
>
width
){
float
xDiff
=
xPos
-
width
;
drawCrease
(
i
,
0
,
width
,
height
-
xDiff
*
sqrt
(
3
));
}
else
if
(
i
<
0
){
float
xDiff
=
-
i
;
drawCrease
(
0
,
xDiff
*
sqrt
(
3
),
i
+
height
/
sqrt
(
3
),
height
);
}
else
{
drawCrease
(
i
,
0
,
i
+
height
/
sqrt
(
3
),
height
);
}
}
// //////// lines
for
(
float
i
=
0
;
i
<
width
+
height
/
sqrt
(
3
);
i
+=
2
*
triangleHeight
/
sqrt
(
3
)){
float
xPos
=
i
-
height
/
sqrt
(
3
);
if
(
i
>
width
){
float
xDiff
=
i
-
width
;
drawCrease
(
width
,
xDiff
*
sqrt
(
3
),
i
-
height
/
sqrt
(
3
),
height
);
}
else
if
(
xPos
<
0
){
float
xDiff
=
-
xPos
;
drawCrease
(
i
,
0
,
0
,
height
-
xDiff
*
sqrt
(
3
));
}
else
{
drawCrease
(
i
,
0
,
i
-
height
/
sqrt
(
3
),
height
);
}
}
// Exit the program
println
(
"Finished."
);
exit
();
}
void
drawCrease
(
float
x1
,
float
y1
,
float
x2
,
float
y2
){
if
(
dashedCreaseLines
){
float
numDashesPerSide
=
5
;
float
dashLength
=
triangleHeight
*
2
/
sqrt
(
3
)
/
(
numDashesPerSide
*
2
);
dashedLine
(
x1
,
y1
,
x2
,
y2
,
dashLength
,
dashLength
);
}
else
{
line
(
x1
,
y1
,
x2
,
y2
);
}
}
void
dashedLine
(
float
x1
,
float
y1
,
float
x2
,
float
y2
,
float
dashLength
,
float
spaceLength
){
pushMatrix
();
translate
(
x1
,
y1
);
rotate
(
atan2
(
y2
-
y1
,
x2
-
x1
));
float
lineLength
=
sqrt
((
y2
-
y1
)
*
(
y2
-
y1
)
+
(
x2
-
x1
)
*
(
x2
-
x1
));
float
partialDash
=
lineLength
/
(
dashLength
+
spaceLength
)
-
floor
(
lineLength
/
(
dashLength
+
spaceLength
));
println
(
partialDash
);
for
(
float
i
=
(
partialDash
+
spaceLength
)
/
2
;
i
<
lineLength
;
i
+=
dashLength
+
spaceLength
){
line
(
i
,
0
,
i
+
dashLength
,
0
);
}
popMatrix
();
}
README.md
View file @
7eb9dba6
# OrigamiSimulator
Live demo at
<a
href=
"http://
git.amandaghassaei.com/OrigamiSimulator"
>
git
.amandaghassaei.com/OrigamiSimulator
</a><br/>
Live demo at
<a
href=
"http://
apps.amandaghassaei.com/OrigamiSimulator"
>
apps
.amandaghassaei.com/OrigamiSimulator
</a><br/>
<img
src=
"crane.gif"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment