Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cuttlefish
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
squidworks
cuttlefish
Commits
1aea5332
Commit
1aea5332
authored
Jun 11, 2019
by
Jake Read
Browse files
Options
Downloads
Patches
Plain Diff
rectangular collision OK, going to try to cleanup
parent
f3a52926
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
view/frect.js
+30
-44
30 additions, 44 deletions
view/frect.js
view/vfloop.js
+1
-4
1 addition, 4 deletions
view/vfloop.js
with
31 additions
and
48 deletions
view/frect.js
+
30
−
44
View file @
1aea5332
...
...
@@ -45,6 +45,7 @@ export default function(radius) {
}
function
apply
(
quad
,
x0
,
y0
,
x1
,
y1
)
{
let
updated
=
false
var
data
=
quad
.
data
,
r
if
(
data
)
{
var
rj
=
data
.
r
...
...
@@ -52,18 +53,16 @@ export default function(radius) {
// prevents from op'ing twice
if
(
data
.
index
>
node
.
index
)
{
let
lg
=
false
if
(
data
.
index
===
2
&&
node
.
index
===
0
&&
tru
e
){
if
(
data
.
index
===
2
&&
node
.
index
===
0
&&
fals
e
){
lg
=
true
}
// quad.data is the node,
// quad contains the x0, y0, x1, y1 ?
// atm, this is websocket and link (I think)
// oook ..
// by domain intersections...
// | -------- x ------ |
// | ------------ x ------ |
// | ---- x --- |
// node left, right (should
n't
be
1
-based
...)
// node left, right (
a note: .bb.x-
should be
0
-based
let
nxl
=
node
.
x
+
node
.
bb
.
x1
let
nxr
=
node
.
x
+
node
.
bb
.
x2
// data left, right
...
...
@@ -78,60 +77,47 @@ export default function(radius) {
let
dyb
=
data
.
y
+
data
.
bb
.
y2
// and check,
if
(
nyt
<
dyt
&&
dyt
<
nyb
||
nyt
<
dyb
&&
dyb
<
nyb
){
updated
=
true
// ok then, compute centers to find a direction for force-exertion
// maybe should also do this in prepare also (and the node data, only once)
if
(
lg
)
console
.
log
(
'
col
'
)
let
cnx
=
(
nxr
-
nxl
)
/
2
+
nxl
let
cny
=
(
nyb
-
nyt
)
/
2
+
nyt
let
cdx
=
(
dxr
-
dxl
)
/
2
+
dxl
let
cdy
=
(
dyb
-
dyt
)
/
2
+
dyt
if
(
lg
)
console
.
log
(
cnx
,
cny
,
'
to
'
,
cdx
,
cdy
)
// x overlap term
let
xo
=
0
if
(
cnx
<
cdx
){
xo
=
nxr
-
dxl
}
else
{
xo
=
nxl
-
dxr
}
if
(
lg
)
console
.
log
(
'
xo
'
,
xo
)
// y overlap term
let
yo
=
0
if
(
cny
<
cdy
){
yo
=
nyb
-
dyt
}
else
{
yo
=
nyt
-
dyb
}
if
(
lg
)
console
.
log
(
'
yo
'
,
yo
)
let
damp
=
0.4
// just assert one axis, otherwise everything ends up
if
(
Math
.
abs
(
xo
)
>
Math
.
abs
(
yo
)){
node
.
vy
-=
yo
*
damp
data
.
vy
+=
yo
*
damp
}
else
{
node
.
vx
-=
xo
*
damp
data
.
vx
+=
xo
*
damp
}
}
}
// x-and-y domains must be intersecting before any action necessary
// so walk a tree of possibilities
// xi, yi are this node's next positions, so x and y are intersections ?
// l is the l of the intersection, by sqrt (len c) and we are comp' to r sqrd
// to avoid the sqrt calc, nice
/*
var x = xi - data.x - data.vx,
y = yi - data.y - data.vy,
l = x * x + y * y
if (l < r * r) {
if (x === 0) x = jiggle(), l += x * x
if (y === 0) y = jiggle(), l += y * y
l = (r - (l = Math.sqrt(l))) / l * strength
//if(node.index === 3) console.log(node)
node.vx += (x *= l) * (r = (rj *= rj) / (ri2 + rj))
node.vy += (y *= l) * r
data.vx -= x * (r = 1 - r)
data.vy -= y * r
}
*/
}
return
}
// end if-data
// If the callback returns true for a given node,
// then the children of that node are not visited; otherwise, all child nodes are visited.
// just gonna do it exhaustively, then
return
false
//x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r
return
updated
//x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r
}
// end apply()
}
/*
function prepare(quad) {
// git r back ... from our list,
// so: we will want to mod this to put the quad's nodes's w/h ?
if (quad.data) return quad.r = radii[quad.data.index]
// so quads are *just* the tree, but related to nodes by the .index, nice
for (var i = quad.r = 0; i < 4; ++i) {
if (quad[i] && quad[i].r > quad.r) {
quad.r = quad[i].r
}
}
} */
function
initialize
()
{
if
(
!
nodes
)
return
var
i
,
n
=
nodes
.
length
,
node
...
...
This diff is collapsed.
Click to expand it.
view/vfloop.js
+
1
−
4
View file @
1aea5332
...
...
@@ -115,10 +115,7 @@ function Floop(View) {
this
.
sim
=
d3
.
forceSimulation
(
nodes
)
.
force
(
'
link
'
,
d3
.
forceLink
(
links
).
distance
((
link
)
=>
{
// nodes are floaters, links have indice, could do like
return
50
}))
.
force
(
'
collide
'
,
d3
.
forceCollide
((
node
,
i
,
nodes
)
=>
{
return
10
return
400
}))
.
force
(
'
rectcollide
'
,
frect
((
node
,
i
,
nodes
)
=>
{
return
node
.
r
...
...
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
sign in
to comment