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
4458c41a
Commit
4458c41a
authored
5 years ago
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
rastering with height map z
parent
cebddea1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/processes/mill/raster/3D
+29
-15
29 additions, 15 deletions
modules/processes/mill/raster/3D
with
29 additions
and
15 deletions
modules/processes/mill/raster/3D
+
29
−
15
View file @
4458c41a
...
@@ -35,6 +35,7 @@ var init = function() {
...
@@ -35,6 +35,7 @@ var init = function() {
var inputs = {
var inputs = {
map:{type:'',label:'height map',
map:{type:'',label:'height map',
event:function(evt){
event:function(evt){
mod.map = evt.detail.map
mod.width = evt.detail.width
mod.width = evt.detail.width
mod.height = evt.detail.height
mod.height = evt.detail.height
mod.xmin = evt.detail.xmin
mod.xmin = evt.detail.xmin
...
@@ -214,11 +215,19 @@ var interface = function(div){
...
@@ -214,11 +215,19 @@ var interface = function(div){
// calculate_path
// calculate_path
//
//
function calculate_path() {
function calculate_path() {
var h = mod.height
var w = mod.width
var xmin = mod.xmin
var xmax = mod.xmax
var ymin = mod.ymin
var ymax = mod.ymax
var zmin = mod.zmin
var zmax = mod.zmax
//
//
// clear SVG
// clear SVG
//
//
var svg = document.getElementById(mod.div.id+'svg')
var svg = document.getElementById(mod.div.id+'svg')
svg.setAttribute('viewBox',"0 0 "+(
mod.width-1)+" "+(mod.height
-1))
svg.setAttribute('viewBox',"0 0 "+(
w-1)+" "+(h
-1))
var g = document.getElementById(mod.div.id+'g')
var g = document.getElementById(mod.div.id+'g')
svg.removeChild(g)
svg.removeChild(g)
var g = document.createElementNS('http://www.w3.org/2000/svg','g')
var g = document.createElementNS('http://www.w3.org/2000/svg','g')
...
@@ -228,29 +237,34 @@ function calculate_path() {
...
@@ -228,29 +237,34 @@ function calculate_path() {
// line loop
// line loop
//
//
var ix = 0
var ix = 0
var iy =
mod.height
-1
var iy =
h
-1
var dx = 1
var dx = 1
var dy = 0
var dy = 0
//var x2 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
var x = xmin+(xmax-xmin)*ix/(w-1)
//var y2 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
var y = ymin+(ymax-ymin)*iy/(h-1)
var z = mod.map[(h-1-iy)*w+ix]
var dz = h*(zmax-z)/(ymax-ymin)
while (1) {
while (1) {
var ixp = ix
var ixp = ix
var iyp = iy
var iyp = iy
var dzp = dz
ix += dx
ix += dx
iy += dy
iy += dy
if (iy <= 0)
break;
var x = xmin+(xmax-xmin)*ix/(w-1)
var y = ymin+(ymax-ymin)*iy/(h-1)
var z = mod.map[iy*w+ix]
var dz = 0.1*h*(zmax-z)/(zmax-zmin)
var line = document.createElementNS('http://www.w3.org/2000/svg','line')
var line = document.createElementNS('http://www.w3.org/2000/svg','line')
line.setAttribute('stroke','black')
line.setAttribute('stroke','black')
line.setAttribute('stroke-width',1)
line.setAttribute('stroke-width',1)
line.setAttribute('stroke-linecap','round')
line.setAttribute('stroke-linecap','round')
line.setAttribute('x1',ixp)
line.setAttribute('x1',ixp)
line.setAttribute('y1',iyp)
line.setAttribute('y1',iyp
+dzp
)
line.setAttribute('x2',ix)
line.setAttribute('x2',ix)
line.setAttribute('y2',iy)
line.setAttribute('y2',iy
+dz
)
g.appendChild(line)
g.appendChild(line)
//var x2 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
//var y2 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
if (iy <= 0)
break;
if (ix == (mod.width-1)) {
if (ix == (mod.width-1)) {
if (dx == 1) {
if (dx == 1) {
dx = 0
dx = 0
...
...
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