Results 1 to 9 of 9
  1. #1
    b_erten is offline Member
    Join Date
    Dec 2009
    Posts
    8
    Rep Power
    0

    Default 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.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by b_erten View Post
    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.
    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.
    I advise you to keep your urgency to yourself. It is after all your urgency, not ours, and your question, while important, is no more important than any other question in this forum.

    Much luck.

  3. #3
    b_erten is offline Member
    Join Date
    Dec 2009
    Posts
    8
    Rep Power
    0

    Default

    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.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,015
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by b_erten View Post
    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.
    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

  5. #5
    b_erten is offline Member
    Join Date
    Dec 2009
    Posts
    8
    Rep Power
    0

    Default

    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?

  6. #6
    b_erten is offline Member
    Join Date
    Dec 2009
    Posts
    8
    Rep Power
    0

    Default

    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

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,015
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by b_erten View Post
    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?
    There is no built-in 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

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    I'm trying to figure out the math but it seems more than trivial to me, probably I'm over-thinking it...

    But I see a Taylor series expansion of a hemisphere and another one for a hemi-rectangle, 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!

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,015
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Fubarable View Post
    I'm trying to figure out the math but it seems more than trivial to me, probably I'm over-thinking it...

    But I see a Taylor series expansion of a hemisphere and another one for a hemi-rectangle, 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!
    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

  1. java app - volume of cylinder
    By tomwaits4noman in forum Java Applets
    Replies: 1
    Last Post: 02-27-2010, 05:12 PM
  2. Morph Cone to Cylinder!
    By aRTx in forum Advanced Java
    Replies: 2
    Last Post: 05-09-2009, 05:50 PM
  3. Cylinder
    By Manikyr in forum New To Java
    Replies: 1
    Last Post: 02-28-2009, 03:58 PM
  4. Creating an object and getting a value from it
    By BrownBread in forum New To Java
    Replies: 2
    Last Post: 11-30-2008, 06:08 AM
  5. Creating object of Type Object class
    By venkatv in forum New To Java
    Replies: 3
    Last Post: 07-17-2007, 03:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •