MelonBP

One-command Colosseum

Sep 21st, 2020 (edited)
1,492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. # Description
  2. This command creates a "colosseum" inside your selection; it really just generates a ring of arches. You can control the height of the arched part, the width of the arches, the thickness above the top of the arches, the number of arches around the ring, the number of floors, and the thickness of the ring all with the six variables (a, b, c, n, m, t).
  3.  
  4. # The command
  5. //g 24 a=0.6;b=0.8;c=0.8;n=12;m=3;t=0.25;u=3*b/n;v=abs(1-sqrt(x^2+z^2)-t/2);w=(abs(atan2(z,x)+pi/n)%(2*pi/n)-pi/n);(((y+1)/2)%(1/m)*m<=a)?abs(w)>=u&&v<=t/2:w^2+(u*((y+1)/2%(1/m)*m-a)/c/(1-a))^2>=u^2&&v<=t/2
  6.  
  7. # The variables
  8. - 'a' controls how high up the circular part of the arch begins, and this value can range from 0 to 1. a=0 means that the arch will start curving inwards right at the base, and a=0.5 means that the arch starts curving inwards halfway up—for example.
  9. - 'b' controls the width of the arches, and this value can also range from 0 to 1. b=0.25 means that the structure is 1/4 arch and 3/4 pillar, b=0.5 means that the structure is 1/2 arch and 1/2 pillar... I hope that makes sense.
  10. - 'c' controls how much padding there is between the top of the arch and the "roof" (or however you would like to name this part), and it also ranges from 0 to 1. You can think of this variable more as how tall the arch is in proportion to the whole structure, because c=0.75 means that the arch will take up 3/4 of the height, and the filled in part above it will take up 1/4 of the height.
  11. - 'n' is the number of arches around the ring. This number can be any whole number—even an odd number.
  12. - 'm' is the number of floors that the whole structure will have, and this number can also be any whole number.
  13. - 't' is the thickness of the whole ring, and this value can range from 0 to 1. t=0.25 means that the ring takes up the outer quarter of the selection's total width, and t=0.5 means that the ring takes up the outer half—for example.
  14.  
  15. # Nerd shit
  16. Okay a lot of people on BR were asking about the math behind how this command works... so I'm going to try my best to explain.
  17.  
  18. To start, I needed to model the shape of an arch with a mathematical expression. I wanted to be able to control some parts of the shape (these variables became 'a', 'b', and 'c'), so I messed around in Desmos and was eventually happy with this: https://www.desmos.com/calculator/acr3uf1nqq.
  19.  
  20. Next, I needed to rotate this shape around a ring a given number of times. The way that I did that was by making the arch function use the angle 'theta' (referring to cylindrical coordinates, read about them here: https://mathworld.wolfram.com/CylindricalCoordinates.html) as the input instead of 'x' or 'z'. In order to specify how many arches to generate around the ring, I added the variable 'n' and essentially had the expression repeat the arch shape every 360/n degrees. More mathematically speaking, I compressed the arch function by a factor of n and replaced 'theta' with 'theta modulo 2*pi/n'. This way, the graph repeats every 360/n degrees (2*pi/n radians) as I wanted, and is also scaled down properly to fit in the space.
  21.  
  22. Then, to allow for several "floors" I added the variable 'm', and replaced the vertical axis 'y' with '(y modulo 1/m) * m'. What this effectively does is repeat the arches vertically every fraction of the total height.
  23.  
  24. Finally, the thickness of the ring is controlled by making sure the shape is only generated between positions with a radius of 1 and radius 't', where 't' is the variable that specifies the thickness.
  25.  
  26. I glossed over a ton of explanation because it's not very interesting and difficult to explain (also because there's no chance that anyone's reading this), but I hope that what I've explained is comprehensive enough and gives some insight to my thought process when writing commands like this.
Add Comment
Please, Sign In to add comment