- Code: Select all
Type Point
x As Number
y As Number
End Type
Type BezierSegment
nodeA As Point
controlA As Point ' Control point
End Type
path1Points = 3 ' Node 3 connects back to node 1 to close the path
path2Points = 5 ' Node 5 connects back to node 1 to close the path
Dim path1(path1Points) As BezierSegment
Dim path2(path2Points) As BezierSegment
Function Union(pathA() As BezierSegment, pathB As BezierSegment) As BezierSegment()
' Returns an array of bezier segments containing the new combined path.
' I want to be able to have functions for other path combinations like division, exclude, intersect, etc, but we'll start with the union.
Dim pathANodes As Number = UBound(pathA)
Dim pathBNodes As Number = UBound(pathB)
' Fancy algorithms I need help with and other supporting functions can come past this point...
End Function
Assuming that all the path data has been filled in with values, how would I create a new path that is the result of a boolean path union (or any other path operation) of path1 and path2?
My hours of googling have shown that I will need to calculate the intersection of the bezier curves, and then more complicated stuff from there. Please keep in mind I'm a high school student in pre-calculus learning fundamental Trig at the moment, and this is for a vector program I'm making as a hobby (been programming for several years). I wasn't able to keep up with all the fancy calculus math I've run into, so please try to explain the algorithms as simply as possible. Any help would be very much appreciated.
Here's some links about path operations and bezier curves:
http://en.wikipedia.org/wiki/Union_(set_theory)
http://kalaalog.com/2007/11/01/inkscape-path-operations-basic-tutorial/
http://stackoverflow.com/questions/109364/bezier-clipping
Again, I would very much appreciate the help. I'm sure my math skills will eventually catch up to my programming knowledge, but until then, I have to beg for handouts from those of you who are awesome at math. This project is very fascinating and important to me and I will be eternally grateful if you help.
Edit: Oh, one other thing. I found a library that does do bezier clipping with path operations, but it is written in Delphi, and I'm not familiar with Delphi's syntax so the code was rather difficult for me to understand since I'm more familiar with C and BASIC-style languages. Here's the link in case you find it helpful: http://www.angusj.com/delphi/clipper.php
