Sg2.9
Sorting Intersections
Recent RSS
Sorting Intersections
From:  Chris Deutsch
Date:  10. October 2011, 17:35

I'm trying to sort intersections, so as to get the order of intersections along the path. This would be easy, if the curveLocation returned by getIntersections() had the offset property, but all I get is the point and the index.

Any ideas? Thanks!

Re: Sorting Intersections
From:  pqbd
Date:  11. October 2011, 02:07

a.getIntersections(b) returns an array of CurveLocations in order with respect to path 'a'

Re: Sorting Intersections
From:  Chris Deutsch
Date:  11. October 2011, 05:54

Ah, cool! But what if my path is intersected by several other paths? I end up with several arrays, all sorted individually. Once they're merged, the sorting no longer applies :(

Re: Sorting Intersections
From:  pqbd
Date:  11. October 2011, 07:40

Merging the arrays won't change the properties of each CurveLocation. As long as you test for intersections with respect to the same path, you can sort by the length property:
mergedArray.sort(function(a, b){ return a.length-b.length})

Re: Sorting Intersections
From:  Chris Deutsch
Date:  11. October 2011, 16:16

Sweeeeet! Thanks so much! I hadn't found the length property in the reference, nor was it showing up when printing the array itself. How come you know of this?

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Grid Generator 04.01.12