GithubHelp home page GithubHelp logo

vasturiano / d3-force-surface Goto Github PK

View Code? Open in Web Editor NEW
21.0 4.0 1.0 135 KB

A multi-surface elastic collision force type for the d3-force simulation engine

License: MIT License

JavaScript 100.00%
d3js elastic-collision force force-directed-graphs physics-simulation surface impact simulation graph-theory

d3-force-surface's People

Contributors

vasturiano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

muisedestiny

d3-force-surface's Issues

Consider a more succinct/standard surface specification

Following the example from the readme, I've specified a bounding box for my simulation as follows:

const [ x1, x2, y1, y2 ] = [ -width/2, width/2, -height/2, height/2 ]
this.simulation.force('bounding-box',
	forceSurface().surfaces([
		{from:{x:x1,y:y1},to:{x:x2,y:y1}}, // top
		{from:{x:x1,y:y2},to:{x:x2,y:y2}}, // bottom
		{from:{x:x1,y:y1},to:{x:x1,y:y2}}, // left
		{from:{x:x2,y:y1},to:{x:x2,y:y2}} // right
	]).radius(n=>n.radius).elasticity(0)
)

This works great (Yay!) but it also strikes me as very verbose and hard to read. In the geospatial world, we often specify bounding boxes as [[x1,y1],[x2,y2]] (i.e. [top-left],[bottom-right]).

Or alternatively an arbitrary polyline could be specified as a series of sequential points given as [x,y] coordinates. Thus my bounding box would be [[x1,y1],[x2,y1],[x2,y2],[x1,y2],[x1,y1]] with five points defining four surfaces.

It would be nice if these more succinct formats could be parsed as well. This could even allow some direct interactions with e.g. d3-geo, though I have a feeling this force would scale badly for complex (multi)polygons. Still, there might be some really interesting use cases there.

Anyway, just a friendly suggestion. This library is exactly what I was looking for - thanks for your work on this!

Rectange surface collision

Hello,

Thank You for this nice surface collision force algorithm. Is there a way to specify the width and height of a node instead of only the radius?

That would be really cool!

Best,
Jan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.