Search Unity

Creating cylinders with side length of X

Discussion in 'World Building' started by dgoyette, Dec 27, 2018.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    When creating a new cylinder, I'm able to enter the radius of the object, but not the side length. Sometimes I want a cylinder where each side is X units, such that I can add more sides but keep the length of the sides constant.

    I tried doing the math on this, and found this:

    https://www.mathopenref.com/apothem.html

    According to that size, the ratio of the length of the radius to the length of the side should be:

    upload_2018-12-27_13-14-20.png

    (I believe what they refer to as apothem here, ProBuilder calls the radius.)

    However, I tried plugging in values for this while creating an octagon, aiming for a side length of 1, but I don't get the right results. According to the formula, it should be:

    1 / [2*tan(180/8)] = 1.207 = radius

    When I used 1.207 as the radius, the shape falls a little short of being 1 meter to the side:

    upload_2018-12-27_13-16-24.png

    Is the Radius here not the apothem of the shape? Or do you know a formula I could use to answer a question like, "To get a cylinder of N sides, each of X length, the radius should be....?"
     
  2. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    Just my personal guess: this may be related to how the radius is interpreted in pb and the formula; it may be that the formula describes different shape definition points (where the sided shape forms the 'cylinder') Touching from the outside or actual midpoints of the sides.
    Bad scribble for confusion clarification:
    Untitled-1.jpg
     
  3. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Co-rectamongo. That's a neat feature idea though- I don't see why we couldn't make this an available value :) Thanks!
     
    dgoyette likes this.