Skip to content

Instantly share code, notes, and snippets.

@exa18
Last active May 25, 2020 13:57
Show Gist options
  • Save exa18/9599ec73f92601901a3ca90700aebd19 to your computer and use it in GitHub Desktop.
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/ )
<?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