We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Pages: 1 2 
2D extrusions (Read 3921 times)
2D extrusions
Sep 29th, 2009, 10:38pm
 
Hello-

Does anyone have any input on how to extrude a 2d polygon along a 2d path?  

I can't quite figure the vector maths...  

Re: 2D extrusions
Reply #1 - Sep 30th, 2009, 9:54am
 
having problems visualising what you need.

are you extruding the 2d polygon in the same plane as it currently lies? or 'outwards'?
Re: 2D extrusions
Reply #2 - Oct 1st, 2009, 8:46am
 
I want to extrude an arbitrary polygon along any arbitrary 2d path..  So a circle extruded along a line becomes a cylinder.  Or, a circle extruded along a circle becomes a torus.

The straight line case is easy, and I already have that working fine..  Its the arbitrary path that is proving tricky..
Re: 2D extrusions
Reply #3 - Oct 1st, 2009, 8:50am
 
its not exactly the same, but it was dealing with similar problems. creating 3d object along a path. maybe it helps http://processing.org/discourse/yabb2/?num=1252940559
Re: 2D extrusions
Reply #4 - Oct 1st, 2009, 9:04am
 
like this?

http://supercoldmilk.com/ac3dplug/extpath_scale.html

(there's code there. it's c++ and a bit dense but...)
Re: 2D extrusions
Reply #5 - Oct 1st, 2009, 9:11am
 
there's also GLE, a Tubing and Extrusion extension for OpenGL

http://linas.org/gle/

but i can't find a jogl version
Re: 2D extrusions
Reply #6 - Oct 1st, 2009, 9:17am
 
Ardor3D seems to be a java library that makes that possible
http://www.ardor3d.com/

http://ardor3d.com/release/0.5/javadoc/ardor3d-core/com/ardor3d/scenegraph/shape/Extrusion.html
Re: 2D extrusions
Reply #7 - Oct 1st, 2009, 9:38am
 
it feels like you just have to join the points in the old polygon with the corresponding points in a polygon that's been translated by your 2d vector. but, given that you mention a torus, the plane that all the translated points can lie in can also change, if you see what i mean. this plane will be perpendicular to the vector, the vector will define the new plane.

that ardor3d sounds interesting but for a site about 3d graphics it is sadly lacking in the pictures department 8)

oh, he has a blog with some - http://blog.renanse.com/search/label/Ardor3D
Re: 2D extrusions
Reply #8 - Oct 1st, 2009, 10:16am
 
Hey guys- thanks for the replies and links!

The supercoldmilk stuff is very close to what I'm trying to do, and the source code is fairly readable..  GLE pretty much does exactly what I need also, but I want to write my own- as this is only step one in the effect I'm going for..  

I will look into this more and keep you posted.  In the meantime I am trying to find a pseudocode/explanation of what exactly needs to happen vector wise..  

Re: 2D extrusions
Reply #9 - Oct 1st, 2009, 2:48pm
 
here's something you might be able to start with:
http://www.davebollinger.com/works/p5/splineextrude/

though note that that code is pre-1.0, so you'll need to change "PMatrix" to "PMatrix3D", and change the method "mult3" to just "mult".  (it also uses float[3]'s since PVector wasn't available back then, you could optionally replace with PVector's now)
Re: 2D extrusions
Reply #10 - Oct 1st, 2009, 11:53pm
 
Thats interesting, what exactly is Pmatrix for? Its new to me. couldnt find any good documentation. But looks like i should take a closer look at it.
Re: 2D extrusions
Reply #11 - Oct 2nd, 2009, 2:08am
 
Hey Dave, i just thought about PMatrix again.
I am working on a project right now where create a helix. thats pretty easy, but know i thought about bending it and this is getting quite complicated. As i still dont know what Pmatrix actually does i thought it might be usefull in this case. is it?
Re: 2D extrusions
Reply #12 - Oct 2nd, 2009, 10:55am
 
the question "what is a matrix" is a bit too broad to cover here, google "linear algebra" for example.

however, in this context, it's ok to imagine a matrix as a set of of 3 orthogonal axes, like a little miniature coordinate system that you can control, and that's capable of transforming points INTO that coordinate system.

you'd typically start with an identity matrix, that corresponds exactly to the default x/y/z axes.  So if you were to transform the point <1,2,3> you'd get the same point <1,2,3> back.

however, if you translate the matrix along z by 5 units, that same point would then be transformed to <1,2,8>.   corresponding things happen when you scale or rotate the matrix then transform the original point - the resulting point is now translated/scale/rotated to match the current state of the matrix.

if you were to connect the results from transforming that point a number of times you'd get a line of some sort, roughly describing the "path" that the matrix has "travelled". (particularly if the point you're transforming is <0,0,0> then each point is the origin of where the matrix "was" at that moment)

if you instead had a SET of points describing a "shape" (say an approximated circle) you could repeatedly translate/rotate/scale the matrix and transform those points to create an extruded mesh of points (and then probably draw tris or quads between subsequent sets), turning that flat "circle" into a cylinder or other twisted tube-like form.  (the exact form will depend on what transforms are applied to the matrix)

imagine repeatedly transforming the matrix with "translate by 1 unit along z, rotate by 10 degrees around x" - after 36 iterations of that the matrix would have travelled in a circle.  if you had been transforming a set of points (flat x/y's on the z=0 plane) that represented a circle, the result would be a mesh describing a torus.  if there had additionally been some translation along y (or, more properly, some rotation around x, to give y "inclination"), then the result would be a mesh describing a helix (which you can just imagine as a torus that has been "pulled apart", and you could continue rotating/translating to extend the helix further)  add in some scaling, and you can "taper" it as well.

..do it over and over and over again with variations, and you might get something like this:
...

hth
Re: 2D extrusions
Reply #13 - Oct 2nd, 2009, 11:04am
 
ok, that makes sense. i never know that it exists but it seems to be really useful.

still, is there a reason why there is no documentation in the references? some examples and explanation would be helpful. although you already offered one.

Only thing i could find were in the Dev section
http://dev.processing.org/reference/core/javadoc/processing/core/PMatrix3D.html etc.
Re: 2D extrusions
Reply #14 - Oct 6th, 2009, 9:26am
 
Ahh, thanks Dave-

That's a nice clean solution.  I like how you converted to spherical coords.. That was one thing I didn't think of that should help with the twisting problems I was having.   Thanks!!
Pages: 1 2