Using Maya curve commands you could first separate the curve into segments, by selecting curve points around the curve edit points and calling “Detach Curves”. Then you’d select all the segments and call “Intersect Curves” to get the intersections.
The ugly thing about this is that the Intersect Curves node will give you warnings in case it won’t find any intersection. Also you’d have intersections on the points where 2 continuous segments meet. So might want to do some little scaling to the curve points to hack around that.
This would give you intersections in some Maya MEL, hacky way
If you’re like me, appreciating a clean mathematical solution this might help :
First of all you need to check whether 2 segments intersect.
If the curve has linear interpolation as on the picture, you could reduce this to checking line segment intersections.
If the curve is cubic you’d have to separate it to segments, each of which is polynomial of 3’rd degree. You’d have to calculate the polynomial here, which would require getting 4 points on a segment (4 coefficients in 3’rd degree polynomial).
To check if there’s intersection you could subtract the polynomials of first and second segments and find its roots (possible for 3’rd degree polynomial).
Now to check if the curve has self-intersections, you subdivide it to segments (probably by edit points), and check intersection between each pair of segments.
So you check segment 1 with segment 2, then 1 with 3, 1 and 4, etc. Then 2 with 3, 2 with 4, etc. This isn’t very efficient, but fairly simple to implement without any introduction of grid or BSP like optimizations.
The numerical approach you started with is also very interesting and could work. I will post when I’ll get any ideas about it
Hope it helps,