Last active
May 25, 2020 13:57
-
-
Save exa18/9599ec73f92601901a3ca90700aebd19 to your computer and use it in GitHub Desktop.
Oblicz długość siatki budowlanej w rolce oraz powierzchnie ( http://sandbox.onlinephpfunctions.com/ )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function circuit($sr){ | |
return (2*pi() * ($sr/2)); | |
} | |
/* | |
Wprowadź dane: | |
gr = gramatura w g/m2 | |
Wymiary w cm: | |
s = średnica wałka (na który nawinięta jest siatka) | |
e = średnica rolki | |
h = wysokość siatki | |
*/ | |
$gr = 160; | |
$s=5.2; | |
$e=7.6; | |
$h = 100; | |
/* | |
Przygotuj dane wejściowe | |
*/ | |
$gr = $gr/10000 *2; | |
$h = $h/100; | |
$parts=round(($e-$s)/$gr,2); | |
$whole = (int)$parts; | |
$parts = round($parts-$whole,2); | |
echo "Pełnych nawinięć jest $whole i częściowe $parts \n"; | |
$long=0; | |
$x=$s; | |
$i=$whole; | |
while ( $i>0 ) { | |
$o = circuit($x); | |
$long += $o; | |
$x += $gr; | |
$i--; | |
} | |
if ($parts>0) { | |
$o = circuit($x); | |
$long += $parts*$o; | |
} | |
echo "MAX -> Obwód: $o, sr=$x \n\n"; | |
$long = round( $long/100 , 2); // zamień cm -> m | |
$area = round($long * $h,2); // obicz powierzchnie w m2 | |
echo "Długość nawinięcia: $long m, Powierzchnia: $area m2"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment