예제 #1
0
 public static function makeStringFromData(array $data = [], array $options = [])
 {
     if (count($data) !== self::dataByteCount) {
         throw new \LengthException('Invalid data array. Needs to contain ' . self::dataByteCount . ' bytes');
     }
     $coeffR = TH_0x00::makeStringFromData(array_slice($data, 0, TH_0x00::dataByteCount));
     $coeffI = TH_0x00::makeStringFromData(array_slice($data, TH_0x00::dataByteCount, TH_0x00::dataByteCount));
     $str = dec2frac($coeffR) . '+' . dec2frac($coeffI) . 'i';
     $str = str_replace('+-', '-', $str);
     return $str;
 }
예제 #2
0
 public static function makeStringFromData(array $data = [], array $options = [])
 {
     if (count($data) !== self::dataByteCount) {
         throw new \LengthException('Invalid data array. Needs to contain ' . self::dataByteCount . ' bytes');
     }
     $coeff = TH_0x00::makeStringFromData(array_slice($data, 0, TH_0x00::dataByteCount));
     $str = $coeff !== '0' ? dec2frac($coeff) . '*π' : '0';
     // Improve final display
     $str = str_replace('+1*', '+', $str);
     $str = str_replace('(1*', '(', $str);
     $str = str_replace('-1*', '-', $str);
     $str = str_replace('(-1*', '(-', $str);
     $str = str_replace('+-', '-', $str);
     return $str;
 }
예제 #3
0
 public static function makeStringFromData(array $data = [], array $options = [])
 {
     if (count($data) !== self::dataByteCount) {
         throw new \LengthException('Invalid data array. Needs to contain ' . self::dataByteCount . ' bytes');
     }
     $coeffR = TH_0x00::makeStringFromData(array_slice($data, 0, TH_0x00::dataByteCount));
     $coeffI = TH_0x00::makeStringFromData(array_slice($data, TH_0x00::dataByteCount, TH_0x00::dataByteCount));
     $str = ($coeffR !== '0' ? dec2frac($coeffR) . '+' : '') . ($coeffI !== '0' ? $coeffI . '*π*i' : '');
     // Improve final display
     $str = str_replace('+1*', '+', $str);
     $str = str_replace('(1*', '(', $str);
     $str = str_replace('-1*', '-', $str);
     $str = str_replace('(-1*', '(-', $str);
     $str = str_replace('+-', '-', $str);
     // Shouldn't happen - I don't believe the calc generate such files.
     if ($str === '') {
         $str = '0';
     }
     return $str;
 }
예제 #4
0
function getReduceArray($pointsNum, $maxPointsNum)
{
    global $reduceArray;
    if ($pointsNum <= $maxPointsNum) {
        return array(1);
    }
    $ratio = $maxPointsNum / $pointsNum;
    list($n, $d) = dec2frac($ratio);
    //echo "$pointsNum / $maxPointsNum have ratio=$ratio, we selected ".($n/$d)." with $n/$d<BR>";
    //echo "it will result in ".$pointsNum*($n/$d)." points<BR>";
    $arr = array();
    if ($n == 1) {
        //simple case mod $d
        $arr[0] = 1;
        for ($i = 1; $i < $d; $i++) {
            $arr[$i] = 0;
        }
    } else {
        if ($d - $n == 1) {
            // also simple fill in all slots with 1 except last
            for ($i = 0; $i < $d - 1; $i++) {
                $arr[$i] = 1;
            }
            $arr[$d - 1] = 0;
        } else {
            if (is_array($reduceArray[$n][$d])) {
                return $reduceArray[$n][$d];
            } else {
                echo "getReduceArray() internal error<BR>";
            }
        }
    }
    return $arr;
}
function post_exif()
{
    global $post;
    $id = intval($post->ID);
    $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    foreach ($attachments as $id => $attachment) {
        $m = get_post_meta(intval($id), '_wp_attachment_metadata', true);
    }
    ?>

	<table class="photo-tech" >

	<?php 
    if ($m['image_meta']['aperture']) {
        ?>
	<tr>
	<th width="100">Aperture:</th>
	<td>f/<?php 
        echo $m['image_meta']['aperture'];
        ?>
</td>
	</tr>
	<?php 
    }
    ?>

	<?php 
    if ($m['image_meta']['focal_length']) {
        ?>
	<tr>
	<th>Focal Length:</th>
	<td><?php 
        echo $m['image_meta']['focal_length'];
        ?>
mm</td>
	</tr>
	<?php 
    }
    ?>

	<?php 
    if ($m['image_meta']['iso']) {
        ?>
	<tr>
	<th>ISO:</th>
	<td><?php 
        echo $m['image_meta']['iso'];
        ?>
</td>
	</tr>
	<?php 
    }
    ?>

	<?php 
    if ($m['image_meta']['shutter_speed']) {
        ?>
	<tr>
	<th>Shutter:</th>
	<td><?php 
        $t = dec2frac($m['image_meta']['shutter_speed']);
        echo $t . ' sec';
        ?>
</td>
	</tr>
	<?php 
    }
    ?>

	<?php 
    if ($m['image_meta']['camera']) {
        ?>
	<tr>
	<th>Camera:</th>
	<td><?php 
        echo $m['image_meta']['camera'];
        ?>
</td>
	</tr>
	<?php 
    }
    ?>

	</table>

	<?php 
}