Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mods
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
mods
Commits
93f3a682
Commit
93f3a682
authored
7 years ago
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
add pyramid
parent
b665bbde
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
files.html
+1
-0
1 addition, 0 deletions
files.html
modules/frep/shapes/3D/pyramid
+173
-0
173 additions, 0 deletions
modules/frep/shapes/3D/pyramid
modules/index.js
+1
-0
1 addition, 0 deletions
modules/index.js
with
175 additions
and
0 deletions
files.html
+
1
−
0
View file @
93f3a682
...
...
@@ -73,6 +73,7 @@
<a
href=
'./modules/frep/shapes/3D/cube'
>
cube
</a><br>
<a
href=
'./modules/frep/shapes/3D/cylinder'
>
cylinder
</a><br>
<a
href=
'./modules/frep/shapes/3D/function'
>
function
</a><br>
<a
href=
'./modules/frep/shapes/3D/pyramid'
>
pyramid
</a><br>
<a
href=
'./modules/frep/shapes/3D/sphere'
>
sphere
</a><br>
<a
href=
'./modules/frep/shapes/3D/torus'
>
torus
</a><br>
<i>
transforms
</i><br>
...
...
This diff is collapsed.
Click to expand it.
modules/frep/shapes/3D/pyramid
0 → 100755
+
173
−
0
View file @
93f3a682
//
// frep pyramid
//
// Neil Gershenfeld
// (c) Massachusetts Institute of Technology 2018
//
// This work may be reproduced, modified, distributed, performed, and
// displayed for any purpose, but must acknowledge the mods
// project. Copyright is retained and must be preserved. The work is
// provided as is; no warranty is provided, and users accept all
// liability.
//
// closure
//
(function(){
//
// module globals
//
var mod = {}
//
// name
//
var name = 'frep pyramid'
//
// initialization
//
var init = function() {
mod.x0.value = '0'
mod.x1.value = '1'
mod.y0.value = '0'
mod.y1.value = '1'
mod.z0.value = '0'
mod.z1.value = '1'
}
//
// inputs
//
var inputs = {
variables:{type:'',
event:function(evt){
for (var p in evt.detail)
mod[p].value = evt.detail[p]
outputs.variables.event()
outputs.shape.event()
}}}
//
// outputs
//
var outputs = {
shape:{type:'',
event:function(){
var x0 = parseFloat(mod.x0.value)
var x1 = parseFloat(mod.x1.value)
var y0 = parseFloat(mod.y0.value)
var y1 = parseFloat(mod.y1.value)
var z0 = parseFloat(mod.z0.value)
var z1 = parseFloat(mod.z1.value)
var fnx0 = `X-(${x0})-((Z-(${z0}))/((${z1})-(${z0})))*((${x1})-(${x0}))/2`
var fny0 = `Y-(${y0})-((Z-(${z0}))/((${z1})-(${z0})))*((${y1})-(${y0}))/2`
var fnx1 = `(${x1})-X-((Z-(${z0}))/((${z1})-(${z0})))*((${x1})-(${x0}))/2`
var fny1 = `(${y1})-Y-((Z-(${z0}))/((${z1})-(${z0})))*((${y1})-(${y0}))/2`
var fn = `Math.min(${fnx0},${fnx1})`
fn = `Math.min(${fny0},${fn})`
fn = `Math.min(${fny1},${fn})`
fn = `Math.min(Z-(${z0}),${fn})`
fn = `Math.min((${z1})-Z,${fn})`
var variables = ['X','Y','Z']
var limits = [[x0,x1],[y0,y1],[z0,z1]]
var type = 'Magnitude'
var shape = {function:fn,variables:variables,limits:limits,type:type}
mods.output(mod,'shape',shape)}
},
variables:{type:'',
event:function(){
var x0 = parseFloat(mod.x0.value)
var x1 = parseFloat(mod.x1.value)
var y0 = parseFloat(mod.y0.value)
var y1 = parseFloat(mod.y1.value)
var z0 = parseFloat(mod.z0.value)
var z1 = parseFloat(mod.z1.value)
var vars = {x0:x0,x1:x1,y0:y0,y1:y1,z0:z0,z1:z1}
mods.output(mod,'variables',vars)}
}}
//
// interface
//
var interface = function(div){
mod.div = div
//
// x0
//
div.appendChild(document.createTextNode('x0: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 3
div.appendChild(input)
mod.x0 = input
//
// x1
//
div.appendChild(document.createTextNode(' x1: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 3
div.appendChild(input)
mod.x1 = input
div.appendChild(document.createElement('br'))
//
// y0
//
div.appendChild(document.createTextNode('y0: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 3
div.appendChild(input)
mod.y0 = input
//
// y1
//
div.appendChild(document.createTextNode(' y1: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 3
div.appendChild(input)
mod.y1 = input
div.appendChild(document.createElement('br'))
//
// z0
//
div.appendChild(document.createTextNode('z0: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 3
div.appendChild(input)
mod.z0 = input
//
// z1
//
div.appendChild(document.createTextNode(' z1: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 3
div.appendChild(input)
mod.z1 = input
div.appendChild(document.createElement('br'))
//
// output button
//
var btn = document.createElement('button')
btn.style.padding = mods.ui.padding
btn.style.margin = 1
btn.appendChild(document.createTextNode('output'))
btn.addEventListener('click',function(){
outputs.variables.event()
outputs.shape.event()
})
div.appendChild(btn)
}
//
// local functions
//
;
//
// return values
//
return ({
name:name,
init:init,
inputs:inputs,
outputs:outputs,
interface:interface
})
}())
This diff is collapsed.
Click to expand it.
modules/index.js
+
1
−
0
View file @
93f3a682
...
...
@@ -43,6 +43,7 @@ module_menu(' cone','modules/frep/shapes/3D/cone')
module_menu
(
'
cube
'
,
'
modules/frep/shapes/3D/cube
'
)
module_menu
(
'
cylinder
'
,
'
modules/frep/shapes/3D/cylinder
'
)
module_menu
(
'
function
'
,
'
modules/frep/shapes/3D/function
'
)
module_menu
(
'
pyramid
'
,
'
modules/frep/shapes/3D/pyramid
'
)
module_menu
(
'
sphere
'
,
'
modules/frep/shapes/3D/sphere
'
)
module_menu
(
'
torus
'
,
'
modules/frep/shapes/3D/torus
'
)
module_label
(
'
transforms
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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