Daily life math function examples
def afterDiscounted(price,discountRate)
=price*(1−discountRate/100);
def hexTessellate(w,h,s){
if(w<=0||h<=0||s<=0){
return 0;
}
var col=floor(w/(3/2*s));
var row=floor(h/(sqrt(3)*s));
return col*row;
}
def 정육각형타일갯수(가로,세로,타일한변길이)=hexTessellate(가로,세로,타일한변길이);
def rhombusTessellate(w,h,s,θ){
if(w<=0||h<=0||s<=0||θ<=0||θ>=180){
return 0;
}
if(θ>90){
θ=180−θ;
}
var wr=s*(1+cos(θ));
var hr=s*sin(θ);
var col=floor(w/wr);
var row=floor(h/hr);
return col*row;
}
def penroseTileCount(w,h,s){
if(w<=0||h<=0||s<=0){
return 0;
}
var thinAngle=36;
var fatAngle=72;
var thinWidth=s/cos(thinAngle/2);
var thinHeight=s*sin(thinAngle);
var fatWidth=s/cos(fatAngle/2);
var fatHeight=s*sin(fatAngle);
var thinColCount=floor(w/thinWidth);
var thinRowCount=floor(h/thinHeight);
var fatColCount=floor(w/fatWidth);
var fatRowCount=floor(h/fatHeight);
var thinTileCount=thinColCount*thinRowCount;
var fatTileCount=fatColCount*fatRowCount;
var goldenRatio=(1+sqrt(5))/2;
var estimatedTotalTiles=thinTileCount+fatTileCount;
var adjustedThinCount=estimatedTotalTiles/(goldenRatio+1);
var adjustedFatCount=adjustedThinCount*goldenRatio;
var correctionFactor=0.95;
var finalTileCount=(adjustedThinCount+adjustedFatCount)*correctionFactor;
return floor(finalTileCount);
}
def 인구(n,r,y)=인구(n,r,y−1)*(1+r/100);
인구(n,r,0)=n;
def 평(가로,세로)=가로*세로*0.3025;
def 한변(평)=sqrt(평/0.3025);
def productivity(experienceYears){
var baseProductivity=100;
var scalingFactor=0.5;
return baseProductivity*pow(experienceYears,scalingFactor);
}
def factoryTime(units,p1,p2,p3){
var totalProductivity=0;
totalProductivity=totalProductivity+productivity(p1)+productivity(p2)+productivity(p3);
return units/totalProductivity;
}
def 정육각형타일갯수(가로,세로,타일한변길이)=hexTessellate(가로,세로,타일한변길이);
def 마름모갯수(가로,세로,한변길이,각도)=rhombusTessellate(가로,세로,한변길이,각도);
def rhombusTessellate(w,h,s,θ){
if(w<=0||h<=0||s<=0||θ<=0||θ>=180){
return 0;
}
if(θ>90){
θ=180−θ;
}
var wr=s*(1+cos(θ));
var hr=s*sin(θ);
var col=floor(w/wr);
var row=floor(h/hr);
return col*row;
}
def penroseTileCount(w,h,s){
if(w<=0||h<=0||s<=0){
return 0;
}
var thinAngle=36;
var fatAngle=72;
var thinWidth=s/cos(thinAngle/2);
var thinHeight=s*sin(thinAngle);
var fatWidth=s/cos(fatAngle/2);
var fatHeight=s*sin(fatAngle);
var thinColCount=floor(w/thinWidth);
var thinRowCount=floor(h/thinHeight);
var fatColCount=floor(w/fatWidth);
var fatRowCount=floor(h/fatHeight);
var thinTileCount=thinColCount*thinRowCount;
var fatTileCount=fatColCount*fatRowCount;
var goldenRatio=(1+sqrt(5))/2;
var estimatedTotalTiles=thinTileCount+fatTileCount;
var adjustedThinCount=estimatedTotalTiles/(goldenRatio+1);
var adjustedFatCount=adjustedThinCount*goldenRatio;
var correctionFactor=0.95;
var finalTileCount=(adjustedThinCount+adjustedFatCount)*correctionFactor;
return floor(finalTileCount);
}
def penroseTileCountP(w,h,s){
if(w<=0||h<=0||s<=0){
return 0;
}
var thinAngle=36;
var fatAngle=72;
var thinWidth=s/cos(thinAngle/2);
var thinHeight=s*sin(thinAngle);
var fatWidth=s/cos(fatAngle/2);
var fatHeight=s*sin(fatAngle);
var thinColCount=floor(w/thinWidth);
var thinRowCount=floor(h/thinHeight);
var fatColCount=floor(w/fatWidth);
var fatRowCount=floor(h/fatHeight);
var thinTileCount=thinColCount*thinRowCount;
var fatTileCount=fatColCount*fatRowCount;
var goldenRatio=(1+sqrt(5))/2;
var estimatedTotalTiles=thinTileCount+fatTileCount;
var adjustedThinCount=estimatedTotalTiles/(goldenRatio+1);
var adjustedFatCount=adjustedThinCount*goldenRatio;
var correctionFactor=0.95;
var finalTileCount=(adjustedThinCount+adjustedFatCount)*correctionFactor;
return floor(finalTileCount);
}
def 펜로즈타일갯수(가로,세로,마름모변길이)=penroseTileCount(가로,세로,마름모변길이);
def 평수계산함수(가로,세로)=가로*세로*0.3025;
def 평넓이(가로,세로)=가로*세로*0.3025;
def 평의세로(평,a,b)=sqrt((평/0.3025)*(b/a));
def 평의한길이(평,a,b,선택){
if(선택==1){
return 평의가로(평,a,b);
}
else{
return 평의세로(평,a,b);
}
}
def 평의가로(평,a,b)=sqrt((평/0.3025)*(a/b));
def 평의한변대략(평,a,b,선택)=round(평의한길이(평,a,b,선택));
Comments
Post a Comment