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_
   Suggestions
   Software Suggestions
(Moderator: fry)
   cylinder() and cone()
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: cylinder() and cone()  (Read 5366 times)
marcello

WWW Email
cylinder() and cone()
« on: Apr 13th, 2004, 5:28pm »

Hi,
Have you already thought to other 3D primitives as well as box() and sphere()? Why don't you add also something like cylinder() and cone()?
 
Just a suggestion
 
Best Regards,
Marcello
 
toxi_
Guest
Email
Re: cylinder() and cone()
« Reply #1 on: Apr 13th, 2004, 6:34pm »

well, you could always roll your own functions to do that. or in that case use the one i just quickly put together:
 
http://www.toxi.co.uk/p5/cylinder/
 
use horizontal mouse position to adjust resolution, press mouse button to close the bottom caps of the objects.
 
this is 90% based on the sphere() code and hence uses a similar syntax. use cylinderDetail(n) to set mesh resolution, then use either:
 
Code:
cone(radius,height,closed);

if "closed" equals true, the cone will be closed at the bottom...
 
 
Code:
cylinder(topRadius,bottomRadius,height,topClosed,bottomClosed);

again, options to have top/bottom open or not...
 
to use in your own sketches, simply copy&paste all lines including/after [toxi040413]...
 
hth, toxi.
 
marcello

WWW Email
Re: cylinder() and cone()
« Reply #2 on: Apr 13th, 2004, 8:32pm »

Great toxi,
thank you very much. I've seen that you have implemented these two functions giving the possibility to chose details like you have already done with sphereDetail().
 
I've just a question about the processing environment. If these two 3D primitives were implemented directly in the language like sphere() already is, would an hypothetic code using these functions be faster than the code using functions you have here implemented. I don't know in depth these things so probably mine is a silly question.
 
Thank you again,
Marcello
 
arielm

WWW
Re: cylinder() and cone()
« Reply #3 on: Apr 13th, 2004, 8:49pm »

on Apr 13th, 2004, 8:32pm, marcello wrote:
I've just a question about the processing environment. If these two 3D primitives were implemented directly in the language like sphere() already is, would an hypothetic code using these functions be faster than the code using functions you have here implemented. I don't know in depth these things so probably mine is a silly question.

not a silly question (it makes sense in a flash/director world!)
 
anyway, with processing: the "engine" is coded in java, as well as the user's language, so there won't be any difference in term of performance...
 
isn't that great
 
taken from another point of view: one can consider the processing engine, aka Bagel, as "just" another java library.
 

Ariel Malka | www.chronotext.org
marcello

WWW Email
Re: cylinder() and cone()
« Reply #4 on: Apr 13th, 2004, 10:18pm »

Thank you arielm for your answer.
Now I've a better understanding about what processing is. Anyway you are right, processing is awesome. I found out processing just few weeks ago and I haven't words to say how fantastic this environment is for me. I don't know anything about java, nevertheless I was able to realize in few days these two applets:
 
http://web.tiscali.it/jeckyll/P5/Mandelbrot/
http://web.tiscali.it/jeckyll/P5/preview_1/
 
(the last one is still under construction: clicking and dragging the mouse, it is possible to move the camera around the object. Moreover, pressing key "a" and dragging the mouse it is possible to rotate the view around an axis perpendicular to the screen. Thanks to this applet I'm starting to understand the lookat() function)
 
I'm a teacher of mathematics and physics of high schools (in Italy) and now I've a fantastic tool in order to make didactical applets.
 
Thank you again,
Marcello
 
mKoser

WWW Email
Re: cylinder() and cone()
« Reply #5 on: May 19th, 2004, 11:02pm »

i've just written a quick rectangle3D method... not sure what to call it, but i needed a bit more flexibility than what box(int n) offers me.
 
so this one takes x, y, z along with width/height/depth.
 
Code:

void rectangle3D(int x, int y, int z, int w, int h, int d){
  /*
  mikkel crone koser
  www.beyondthree.com
  */
 
  beginShape(QUADS);
  /* top */
  vertex(x-w/2f, y-h/2f, z-d/2f);
  vertex(x-w/2f, y-h/2f, z+d/2f);
  vertex(x+w/2f, y-h/2f, z+d/2f);
  vertex(x+w/2f, y-h/2f, z-d/2f);
   
  /* bottom */
  vertex(x-w/2f, y+h/2f, z-d/2f);
  vertex(x-w/2f, y+h/2f, z+d/2f);
  vertex(x+w/2f, y+h/2f, z+d/2f);
  vertex(x+w/2f, y+h/2f, z-d/2f);
   
  /* left */
  vertex(x-w/2f, y-h/2f, z-d/2f);
  vertex(x-w/2f, y-h/2f, z+d/2f);
  vertex(x-w/2f, y+h/2f, z+d/2f);
  vertex(x-w/2f, y+h/2f, z-d/2f);
   
  /* right */
  vertex(x+w/2f, y-h/2f, z+d/2f);
  vertex(x+w/2f, y-h/2f, z-d/2f);
  vertex(x+w/2f, y+h/2f, z-d/2f);
  vertex(x+w/2f, y+h/2f, z+d/2f);
   
  /* back */
  vertex(x-w/2f, y-h/2f, z-d/2f);
  vertex(x-w/2f, y+h/2f, z-d/2f);
  vertex(x+w/2f, y+h/2f, z-d/2f);
  vertex(x+w/2f, y-h/2f, z-d/2f);
   
  /* front */
  vertex(x-w/2f, y-h/2f, z+d/2f);
  vertex(x-w/2f, y+h/2f, z+d/2f);
  vertex(x+w/2f, y+h/2f, z+d/2f);
  vertex(x+w/2f, y-h/2f, z+d/2f);
  endShape();
}

 
maybe this would make sense to impement as a primitive? (with some fiddle, like openEnds/closeEnds and another name maybe).
 
+ mikkel
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
mKoser

WWW Email
Re: cylinder() and cone()
« Reply #6 on: Sep 12th, 2004, 2:25pm »

just saw that the native processing command 'box()' can do the same as my code above... hmmm, was that always in there
 
http://processing.org/reference/box_.html
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
fry


WWW
Re: cylinder() and cone()
« Reply #7 on: Sep 12th, 2004, 6:29pm »

yeah, box() has been around for a while.. casey and i fretted a bit about whether to include things like cylinder and cone.. we opted against it figuring that folks can write their own (especially as it gets easier to include libraries and other code in future releases), and we didn't exactly want to encourage people to use things like cones.  
 
(there's a tendency when teaching this stuff that people quickly go to the primitives, as soon as people have their flying 3D cube they're not as into learning about bezier-curve shapes and things like that)
 
that said, we oughta make it easier to make non-uniform sorts of shapes.. though that's a task for another library hacker..
 
mKoser

WWW Email
Re: cylinder() and cone()
« Reply #8 on: Sep 12th, 2004, 6:40pm »

i know box() has been there for more than two years now... but i didn't know that you could do box(int, int, int)... ..thanks for answering!
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
TomC

WWW
Re: cylinder() and cone()
« Reply #9 on: Sep 12th, 2004, 7:38pm »

on Sep 12th, 2004, 6:29pm, fry wrote:

that said, we oughta make it easier to make non-uniform sorts of shapes.. though that's a task for another library hacker..

 
If there are any library hackers reading this, you  might like to know that I've got a class for experimenting with extrusions, (a bit like the VRML Extrusion node, for people who know it).
 
It's on my TODO list to clean it up and document it, but I thought I'd post about it here in case people were about to start making one.  If you want to preview where I'm up to, feel free to ask.
 
I've also done some work on a rudimentary scene-graph.
 
fry


WWW
Re: cylinder() and cone()
« Reply #10 on: Sep 12th, 2004, 11:57pm »

on Sep 12th, 2004, 6:40pm, mKoser wrote:
i know box() has been there for more than two years now... but i didn't know that you could do box(int, int, int)..

oh right.. hm, maybe that's changed we sorta go in circles about api sometimes. casey spends a lot of time staring at it with the docs/reference stuff, so we may have added that to improve clarity at the wishes of the consistency polizei.
 
cello

marcello3d WWW
Re: cylinder() and cone()
« Reply #11 on: Sep 13th, 2004, 12:14am »

It's another Marcello.
 
And to be slightly on topic, any chance on box having uv coordinates so we can use textures?
 
Marcello
 
Pages: 1 

« Previous topic | Next topic »