Solved Math adjustment

Discussion in 'Plugin Development' started by Coopah, Oct 15, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Coopah

    Recently a fellow forum member helped me in creating a circular shape which looks like this:
    [​IMG]
    However, I'm wanting to remove the four corner blocks, which should make it look like this:
    [​IMG]
    Current math:
    Code:
    int radius = 3;
    
       for (double x = -radius; x <= radius; x++) {
            for (double z = -radius; z <= radius; z++) {
                if ((x*x)+(z*z) <= radius*radius) {
    Thanks in advanced! :D
     
  2. Offline

    Scimiguy

    @Coopah
    Can you make those pictures a lot smaller

    EDIT: Mis-interpreted what he wanted --snip
     
    Last edited: Oct 15, 2015
  3. Offline

    khave

  4. Offline

    teej107

    If you take off the corners, it'll be a square that is just rotated.
     
  5. Offline

    Coopah

    @khave Don't know what this has to do with cylinders, it's a flat circle lol.
    @teej107 That ain't a square bro... ahhaha
     
  6. Offline

    Scimiguy

    @Coopah

    It actually is a square if you take out those corners.
     
  7. Offline

    mcdorli

    That's a square bro. Ahahahaha
     
  8. Offline

    Coopah

    @mcdorli
    There are four blocks coming off of the current square which counteracts what your saying.

    Also, I'm wanting to remove 4 blocks from the corners. If you think that's a square you're kidding yourself lol.
     
  9. Offline

    DoggyCode™

  10. Offline

    mcdorli

    Please, rotate your view by 45 degrees lol. Maybe change your perspective and not just laugh at somebody, who can do that.
     
    Last edited: Oct 16, 2015
  11. Offline

    Coopah

    @DoggyCode @mcdorli
    [​IMG]
    Looks like a fking square to you two? Apologies for drawing but that explains the basic shape. I'm wanting to cut off the corners.
     
  12. Offline

    Xerox262

    You realise that you're proving yourself incorrect and trying to make fun of the people that you want to help you. Do you want me to draw the square they're talking about and you can see why you're wrong?


    Edit:

    What you have.

    [​IMG]
    What you want
    [​IMG]

    Rotated and shrunk

    [​IMG]
     
    Last edited: Oct 16, 2015
    DoggyCode™ and mcdorli like this.
  13. Offline

    mcdorli

    *insert facepalm meme here* That's a f****ng square, 3 people say the same. Just connect the corners please.
     
    Last edited: Oct 16, 2015
  14. Offline

    Xerox262

    @Coopah Look, I drew the lines to help you, I missed the circle slightly but you get the idea, or at least I hope you understand now.

    Edit: replied to the wrong name :I

    A circle is a cylinder with the same x and z radius...
     
    Last edited: Oct 16, 2015
  15. Offline

    mcdorli

    @Coopah you basically want it look like the water in minecraft, aren't you?

    This is spoonfeeding, but I really want to end this thread. Instead of doing "x*x + y*y <= r * r", do "x + y <= radius", where x and y are the distance from the middle block. You don't need to change anything, except the if statement.
     
    Last edited: Oct 16, 2015
  16. Offline

    Scimiguy

    @Coopah

    As has been clearly shown many times so far, my original code that you used produces a mathematically accurate circle.
    It may not look like a circle, but that's because it's small, and is produced by cubes

    If you change it, it is no longer a circle.. in this case you are making a square
     
  17. Offline

    Coopah

    My apologies, I can see the square.

    This code:
    Code:
    if (x + z <= radius) {
    
    Will only produce this shape?
    [​IMG]
     
  18. Offline

    mcdorli

    Sorry, you need to do Math.abs(x) + Math.abs(z) <= radius. My bad.
    @Coopah
     
    Last edited: Oct 16, 2015
    Coopah likes this.
  19. Offline

    khave

    A cylinder is a cirlce if you don't change the y axis. WE already has this made in the link I gave you.
     
  20. Offline

    mcdorli

    And there is no such thing as a "flat circle", a cicle is always flat, a circle in 3d is a sphere, but this has been said before.
     
  21. Offline

    mythbusterma

    @khave

    Because depending on WorldEdit for something that can be done in 5 lines of code is excellent design.
     
    MrKravis likes this.
  22. Offline

    mcdorli

    @mythbusterma You forgot to put too laughing smilies and a lol message at the end, so dumb people understand the irony too.

    This is basic geometry math, you need to learn math for programming
     
  23. Offline

    Scimiguy

    @mcdorli

    The thing is, this is all spawned from the original code I gave him on another thread to create the circles.
    Seems like he wants squares now
     
  24. Offline

    teej107

Thread Status:
Not open for further replies.

Share This Page