My Computer Forum Computer Science Forum

Go Back   My Computer Forum > Computer Science Forum > Rendering

Rendering Visual Rendering - Computer Graphics, Image Processing, Geometry, Subfield, Animation, Scattering, Transport, Visual Effects


Reply
 
LinkBack Thread Tools Display Modes
November 13th, 2010, 10:40 PM   #1
 
JosephE's Avatar
 
Joined: Nov 2010
Posts: 3
Bezier Vector Path Operations

I have a string of bezier paths that compose a path that is closed back to the first node. I'll use some sort of pseudo-BASIC to represent:

Code:
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/inksc...asic-tutorial/
http://stackoverflow.com/questions/1...ezier-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
JosephE is offline  
 

My Computer Forum is free to register and we welcome everyone!

November 13th, 2010, 11:42 PM   #2
 
JosephE's Avatar
 
Joined: Nov 2010
Posts: 3
Re: Bezier Vector Path Operations

(As for the clipping library I mentioned, the version that supports bezier curve paths is all the way down at the bottom of the linked page.)
JosephE is offline  
November 14th, 2010, 10:46 AM   #3
 
JosephE's Avatar
 
Joined: Nov 2010
Posts: 3
Re: Bezier Vector Path Operations

Oops, implementation mistake on my part. BezierSegment Type needs to be like this since each node has two control points:

Code:
Type BezierSegment
  node As Point
  controlA As Point ' First control point for the node
  controlB As Point ' Second control point for the node
End Type
JosephE is offline  
November 29th, 2011, 03:41 AM   #4
Guest
 
Joined:
Posts: n/a
Re: Bezier Vector Path Operations

I'm of mixed opinions on the value of bezier tools in Quark. ... to just do it in Quark without the extra step of creating a vector file to place.
 
Reply

  My Computer Forum > Computer Science Forum > Rendering

Tags
bezier, operations, path, vector



Search tags for this page
Click on a term to search for related topics.
Thread Tools
Display Modes






Copyright © 2017 My Computer Forum Forum. All rights reserved.