Jump to content
Search Community

Path Intersection

jdw2 test
Moderator Tag

Recommended Posts

Does Greensock have any methods akin to the following in either it's core or in any of the plugins as I am currently having to use Snap svg and would rather not have to rely on additional libraries. Basically these methods in Snap allow you to identify the intersections between two paths even if they have been transformed.  

 

var domesticIntersection = Snap.path.intersection(domesticSupplyPath,worldSupplyPath);
let matrixStuff = d3.select(".demand").node().transform.baseVal.consolidate().matrix;
let matrixObject = Snap.matrix(matrixStuff);
let pathString = Snap.path.map(demandPath,matrixObject);
Link to comment
Share on other sites

Hi @jdw2 :)

 

Welcome to the forum and thanks for joining Club GreenSock/

 

I'm not familiar with Snap, but GSAP does have hitTest().

https://greensock.com/docs/v3/Plugins/Draggable/static.hitTest()

 

We've also had numerous threads about collision detection which may be helpful.  Just do a quick search and several should pop up for you. 

 

Happy tweening and welcome aboard.

Link to comment
Share on other sites

5 hours ago, jdw2 said:

Does Greensock have any methods akin to the following in either it's core or in any of the plugins

 

No. There's not a lot of libraries that can do that.

 

5 hours ago, jdw2 said:

would rather not have to rely on additional libraries

 

You don't need d3 for the code you provided. consolidate is a native method.

https://developer.mozilla.org/en-US/docs/Web/API/SVGTransformList

 

 

  • Like 1
Link to comment
Share on other sites

Just for fun and with smaller footprints than snap, here are some interesting ones I can think of.

 

Kevin Lindsey did some neat stuff with his Intersection.js library http://www.kevlindev.com/geometry/2D/intersections/index.htm And the following was also based upon Kevin’s work https://github.com/signavio/svg-intersections .

 

This page http://svg-polygon.com/ by fhemsher (Francis Hemsher) has some interesting collision / intersection examples also. There also used to be a site called ‘svgdiscovery .com’ by him with tons of cool SVG stuff. You can also find many great SVG posts by him on StackOverflow. But sadly in looking just now, it appears he passed away in March 2020. 😞

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...