FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   curveVertex process question
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: curveVertex process question  (Read 542 times)
flight404

WWW Email
curveVertex process question
« on: Dec 16th, 2004, 7:53pm »

Take a peek at this sketch...
http://www.flight404.com/p5/image/curves.gif
 
So, I have a quad_strip that I am currently using, but it occurs to me that not only are the sides faceted, but I would need more nodes to make a smoothish curve.  So I thought, 'Why not use fewer nodes and connect them with curves instead'.
 
Well, this is proving to be a bit of a puzzle.  Since I am dealing with long strips composed of anywhere between 100 to 2000 segments, I figured QUAD_STRIP would be the best way to go.  
 
But it seems to me that in order to make the curve example work, I would need a curveVertex that would work with only three given points.  I would provide the start point, an anchor point, and an end point.  This would provide one 'side' of each segment.  Then I would cut across the strip using a straigh line. But here comes the problem... in order to keep the QUAD_STRIP going, I would need to continue down the length of the strip, but for the curved sides to work, I would need to backtrack back up the strip in order to make the 2nd curved side.
 
Alas, I fear I have reached a dead end.  Can anyone help me understand if this is even possible and if so, what am i not grasping here.
 
r
 
fjen

WWW
Re: curveVertex process question
« Reply #1 on: Dec 16th, 2004, 10:57pm »

robert,
 
why not use bezierVertex and do per segment: first point, 2x anchor point, end point. that should provide a curve made of 3 points ..
 
and, to solve problem two arrange your data differently. arrange by "quad"-segments not by line-segments. this means:
 
array {
"quad"-object:
- bezier segment left:
    - p1
    - p2
    - p3
- line segment bottom:
    - p1
    - p2
- bezier segment right:
    - p1
    - p2
    - p3
{- line segment top (if needed):
    - p1
    - p2}
}
 
maybe you could provide some code, then i can get a little more detailed with what i meant ...
 
sounds like a perfect solvable problem .. head up!
 
/F
 
fry


WWW
Re: curveVertex process question
« Reply #2 on: Dec 17th, 2004, 6:59pm »

couple things..
 
1. at least initially, i think you actually just want to use a polygon, it'll get turned into triangles anyway.  
 
2. just walk down one side using vertex/curveVertex and then walk up the other side the opposite direction.
 
3. fjen is right about the curve and control points, if the curves work in flash the way i'm guessing they do. processing's two control points are the same as ends of the little blue handles when you're editing a curve in illustrator (to get a corner point you double up the 4th pt and the 1st point of the next segment). my guess is that perhaps flash uses only a single control point, equivalent to the blue handles meeting each other at the same location.  
 
once you have it figured out, you can use bezierPoint() to get the coords at some sort of spacing that seems good, and then make your own QUAD_STRIP that way. this is what bezierPoint is for, but it's another level of difficulty and i'd try to get the thing just drawing first.
 
flight404

WWW Email
Re: curveVertex process question
« Reply #3 on: Dec 17th, 2004, 8:28pm »

I tried using Polygon, but got some polygon concavity error.  Is there a limit to the number of points that you can use to define the polygon, because as it is, there are about 2048 per ribbon.  Polygon seemed to not want me to use that many (or perhaps I was screwing up someplace else).
 
r
 
amoeba

WWW
Re: curveVertex process question
« Reply #4 on: Dec 17th, 2004, 8:45pm »

Hi Robert. I'm not sure there is a hardwired limit to the number of points in a polygon, but as many as 2048 doesn't really make sense. If you need that many points to get the smoothness you want it's much faster to do it as a QUAD_STRIP. That way Processing doesn't need to spend time figuring out the polygon (or worse, messing it up...)
 
Keep in mind that the number of subdivisions required to draw an approximation of a bezier curve with straight lines is typically set to 20 lines. That's a tried and tested average, you can of course go higher if you have noticeable artifacts. So a QUAD_STRIP with 20 subdivisions per curve segment should give you something pretty close to your original sketch. Even if you successfully use bezierVertex() it still gets broken down in subdivisions internally.
« Last Edit: Dec 17th, 2004, 8:49pm by amoeba »  

marius watz // amoeba
http://processing.unlekker.net/
juancarlos

juananorga WWW
Re: curveVertex process question
« Reply #5 on: Jan 3rd, 2005, 7:56am »

on Dec 17th, 2004, 8:28pm, flight404 wrote:
I tried using Polygon, but got some polygon concavity error.

 
I'm not sure about how java draws polygons but in opengl a polygon can not be concave, which would explain your concavity error.
 
Pages: 1 

« Previous topic | Next topic »