Results 1 to 9 of 9
Thread: Creating a cylinder object
 07252010, 06:23 PM #1Member
 Join Date
 Dec 2009
 Posts
 8
 Rep Power
 0
Creating a cylinder object
Hello,
For a class project I need to create a cylinder objects which can be manipulated. I need to manipulates the cylinder parameters because it needs to be gradually transformed to square shaped object.
Does anybody have any idea how should I do it? Currently, I cannot think about anything because I am new to java graphics. It is very urgent that I should finish the whole script in a week.
Thanks to anyone who considers my post.

Your question is not clear to me because I'm not sure how a cylinder, a 3D structure, can be transformed into a square, a 2D structure, nor do you tell us specifically what you don't understand. For general questions/problems such as "I cannot think about anything because I am new to java graphics" about all we can do is refer you to the Sun/Oracle Swing and Graphics tutorials. If on the other hand you state, "I tried this code ...., but got .... result when I wanted ... result" then we can help you more.
It is very urgent that I should finish the whole script in a week.
Much luck.
 07252010, 07:41 PM #3Member
 Join Date
 Dec 2009
 Posts
 8
 Rep Power
 0
When I said it is urgent, I did not mean to ignore other people's question and focus on mine. I just tried to mention how important it is for me to find a reply to my thread. By the way, I'm not a native English speaker so maybe the word urgent was not the suitable one to describe my situation.
You shouldn't waste your valuable time with replying to quotes for my unimportant threads.
 07252010, 07:51 PM #4
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,128
 Blog Entries
 7
 Rep Power
 24
Too much modesty all of a sudden ... perhaps you meant to transform a cyclinder to a cube; if that is so all you have to do is transform a circle (the base of the cylinder) to a square and adjust the height of the cylinder if needed. So basically you have to transform a circle to a square.
kind regards,
Jos
 07252010, 08:00 PM #5Member
 Join Date
 Dec 2009
 Posts
 8
 Rep Power
 0
Dear Jos,
Thank you for the reply.
I could draw a 2D square and circle with fillrect, and filloval function. But in my script, I need a gradual transforming between rectangular and circle. Is this possible with using basic java methods or do I have to create a method myself?
 07252010, 08:11 PM #6Member
 Join Date
 Dec 2009
 Posts
 8
 Rep Power
 0
Anyway, thanks for the criticism, this was my first post on a forum, next time I will try to be more clear and specific.
Best,
Begum
 07252010, 08:28 PM #7
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,128
 Blog Entries
 7
 Rep Power
 24
There is no builtin method that does it all for you, you have to write your own method for that but it isn't too difficult. If you want to transform a circle to a square you have to define some points (x,y) on the circle that gradually have to move to points (x',y') on a square. A bit of math shows you how to do it.
kind regards,
Jos

I'm trying to figure out the math but it seems more than trivial to me, probably I'm overthinking it...
But I see a Taylor series expansion of a hemisphere and another one for a hemirectangle, and multiply each series respectively by coefficients A and B such that A + B = 1, and A starts at 1 and goes to 0 as B starts at 0 and goes to 1,.... Yikes!
 07252010, 08:43 PM #9
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,128
 Blog Entries
 7
 Rep Power
 24
Nah, think of the first octant of a circle; points on that octant need to be moved to a straight line (the first 'octant' of the square). take the difference (x,y) of a point on the circle and a point (x',y') on the square and gradually (linearly) move (x,y) towards (x',y') in a fixed number of steps. It's too bad I can't sketch here ;)
kind regards,
Jos
Similar Threads

java app  volume of cylinder
By tomwaits4noman in forum Java AppletsReplies: 1Last Post: 02272010, 06:12 PM 
Morph Cone to Cylinder!
By aRTx in forum Advanced JavaReplies: 2Last Post: 05092009, 05:50 PM 
Cylinder
By Manikyr in forum New To JavaReplies: 1Last Post: 02282009, 04:58 PM 
Creating an object and getting a value from it
By BrownBread in forum New To JavaReplies: 2Last Post: 11302008, 07:08 AM 
Creating object of Type Object class
By venkatv in forum New To JavaReplies: 3Last Post: 07172007, 03:33 PM
Bookmarks