public function cornealCylAndAxis($plus = 0) { $pwr = $this->cornealCyl(1, 1); if ($plus) { return "+" . $pwr . " x " . numToAxisString(fixAxis($this->cornealCylAxis() + 90)); } return "-" . $pwr . " x " . numToAxisString($this->cornealCylAxis()); }
function prettyRxString($sph = 0, $cyl = 0, $axis = 0, $round = 0.25) { $axis = fixAxis($axis); $sphString = numToDiopterString($sph, 1, $round); $cylString = numToDiopterString($cyl, 1, $round); $axisString = "x " . numToAxisString($axis); if (abs($sph) < $round / 2) { $sphString = @"plano"; } if (abs($sph) < $round / 2 && abs($cyl) < $round / 2) { return @"plano"; } if (abs($cyl) < $round / 2) { $cylString = "sph"; $axisString = ""; } return $sphString . " " . $cylString . " " . $axisString; }
function kStringBreaker($str) { //echo ($str); $str = str_replace(" ", "", $str); //remove whitespace $returnK = new KeratoObject(); //if just a single number is provided if (is_numeric($str)) { $returnK->num1 = $str; $returnK->num2 = $str; $returnK->meridian1 = 90; return $returnK; } $kParts = explode("/", $str); if (count($kParts) < 2) { $k1 = $str; $k2 = $str; } else { $k1 = $kParts[0]; //should be 42@90 ..or 42 $k2 = $kParts[1]; //should be 42@90 ..or 42 } if (is_numeric($k1)) { //if the first half is just a number eg)43 $num1 = $k1; } else { $k1parts = explode("@", $k1); if (count($k1parts) > 1) { $num1 = $k1parts[0]; $meridian1 = $k1parts[1]; } else { //didn't contain "@" $num1 = intval($k1); } } if (is_numeric($k2)) { //if the second half is just a number eg)43 $num2 = $k2; } else { $k2parts = explode("@", $k2); if (count($k2parts) > 1) { $num2 = $k2parts[0]; $meridian2 = $k2parts[1]; } else { //didn't contain "@" $num2 = intval($k2); } } if (!isset($meridian2)) { if (isset($meridian1)) { $meridian2 = fixAxis($meridian1 + 90); } else { $meridian2 = 90; } } if (!isset($meridian1)) { if (isset($meridian2)) { $meridian1 = fixAxis($meridian2 + 90); } else { $meridian1 = 180; } } if (!$num2) { $num2 = $num1; } $returnK->num1 = $num1; $returnK->num2 = $num2; $returnK->meridian1 = $meridian1; $returnK->meridian2 = $meridian2; return $returnK; }
public function subtractRx($rx2) { //this & rx2 are Rx objects. "This" is usually the MR, rx2 is the spectacles $newAxis = 0; $newSph = 0; $gamma = 0; $F2 = 0; $xSph = $this->sphP(); $xCyl = $this->cylP(); $xAxis = $this->axisP(); //echo $this->prettyString(); //echo "<br/>"; //echo $rx2->prettyString(); //echo "<br/>"; if ($rx2->cylP() > 0.375) { //if the cyl is significant $theta = $xAxis - $rx2->axisP(); //find the smallest diff btwn the axes if ($theta > 90) { $theta = 180 - $theta; } if ($theta < -90) { $theta = -180 - $theta; } //echo "<p>theta: " . $theta . "</p>"; $a = $xCyl * sin(deg2rad(2 * $theta)); //trace ("a:"+a); $b = $xCyl * cos(deg2rad(2 * $theta)) - $rx2->cylP(); //trace ("b:"+b); $F2 = sqrt($a * $a + $b * $b); if ($b < 0) { $F2 = -$F2; } //this line added 4/7/04 if ($F2 != 0) { $gamma = rad2deg(asin($a / $F2) / 2); } //echo "<p>gamma: " . $gamma . "</p>"; $newAxis = $rx2->axisP() + $gamma; //echo "<p>newAxis : " . $newAxis . "</p>"; $newSph = $xSph - $rx2->sphP() - ($rx2->cylP() + $F2 - $xCyl) / 2; } else { // rx2 is essentially spherical $newSph = $xSph - $rx2->sphP(); $F2 = $xCyl; $newAxis = $xAxis; } //trace("newAxis ",newAxis); //trace("a = "+a);trace("b = "+b);trace ("$F2 = "+$F2);trace("gamma:"+gamma);trace("new axis:"+newAxis);trace("new sph:"+newSph); $tempObj = new RxObject(); $tempObj->sph = $newSph; $tempObj->cyl = $F2; $tempObj->axis = fixAxis($newAxis); //trace(eye+" residual Rx:"+tempObj.prettyString("+", false)); return $tempObj; }
function getCrossFromParams($params) { extract($params); //if (!isset($round) ) $round = .12; if (!isset($totalSize)) { $totalSize = 140; } if (!isset($crossSize)) { $crossSize = $totalSize * 0.8; } $halfCross = $crossSize / 2; $gutter = ($totalSize - $crossSize) / 2; // label: 0= no label, 1=label in given cyl type; 2= both +/- cyl; //3= if minus show minus, if plus show minus and plus if (!isset($label)) { $label = 0; } if (!isset($doVertex)) { $doVertex = null; } if (!isset($doSphEquiv)) { $doSphEquiv = null; } if (!isset($rxString) && !isset($kString)) { return null; } //get the numbers and meridians if an Rx string is passed if (isset($rxString)) { $rxObject = rxStringBreaker($rxString); if ($doVertex == 1) { $rxObject = $rxObject->diffVertex(0); } if ($doSphEquiv == 1) { $rxObject = rxStringBreaker($rxObject->sphericalEquivalent()); } $num1 = numToDiopterString($rxObject->sphP(), 1); $num2 = numToDiopterString($rxObject->sphP() + $rxObject->cylP(), 1); $meridian1 = $rxObject->axisP(); } if (isset($kString)) { // echo "string: " . $kString; $kObject = kStringBreaker($kString); $num1 = numToDiopterString($kObject->pwr1D(), 0) . "<br>(" . numToMMString($kObject->pwr1mm()) . ")"; $num2 = numToDiopterString($kObject->pwr2D(), 0) . "<br>(" . numToMMString($kObject->pwr2mm()) . ")"; $meridian1 = $kObject->meridian1; $meridian2 = $kObject->meridian2; if ($label > 0) { $niceString1 = $kObject->prettyStringD(); } if ($label == 2) { $niceString2 = $kObject->prettyStringMM(); } } if ($label > 0 && isset($rxString)) { if ($label == 1) { $niceString1 = $doVertex == 1 ? $rxObject->prettyStringMinus() : $rxObject->prettyString(); } if ($label == 2) { $niceString1 = $rxObject->prettyStringPlus(); $niceString2 = $rxObject->prettyStringMinus(); } if ($label == 3) { $plusCyl = $rxObject->isPlusCyl(); //the cyl type the original Rx was given in $niceString1 = $rxObject->prettyStringMinus(); if ($plusCyl == 1) { $niceString2 = "(" . $rxObject->prettyStringPlus() . ")"; } } } if (isset($bgImage)) { switch ($bgImage) { case "lens": if (isset($rxObject) && $rxObject->isToric() == 1) { $image = "/images/crosses/toric_lens.png"; } else { $image = "/images/crosses/sphere_lens.png"; } break; case "spherelens": $image = "/images/crosses/sphere_lens.png"; break; case "toriclens": $image = "/images/crosses/toric_lens.png"; break; default: $image = $bgImage; } } //start the html and CSS we'll be returning $html = ""; if (isset($header)) { $html .= "<div class='opticalCrossLabel' style='font-weight:bold; text-align: center; margin: .5em;'>{$header}</div>"; } $canvasCSS = "position: relative; height:" . $totalSize . "px; width: " . $totalSize . "px;"; if (isset($image)) { $canvasCSS .= "background-image: url(" . $image . "); background-repeat:no-repeat;background-position:center; "; } $html .= "<div style='{$canvasCSS}'>"; $labelCSS = "width: 40px; height: 25px; position: absolute; text-align: center;"; //echo("toric " . $rxObject ->isToric() ); //don't need to worry about optical crosses if the lens is spherical if (isset($rxObject) && $rxObject->isToric() == 0) { // a spacer div $html .= "<div style='margin: 0 " . $gutter . "px " . $gutter * 2 . "px; width: " . $crossSize . "px; height: " . $crossSize . "px'> </div>"; $html .= "<div style=' " . $labelCSS . " ; top: " . ($halfCross + 4) . "px; left: " . ($halfCross - 8) . "px; '>"; $html .= numToDiopterString($num1, 1); $html .= "</div>"; } else { //toric lenses //an url to the optical cross images (it will be completed below - we need to calculate the angle to get the correct image) if (!isset($crossImage)) { $crossImage = "http://www.eyedock.com/images/crosses/cross"; } if (!isset($meridian2)) { $meridian2 = fixAxis($meridian1 + 90); } //find the closest 10 deg increment (for the image) $imageAngle = fixAxis($meridian1); $imageAngle = round($imageAngle / 10) * 10; if ($imageAngle > 90) { $imageAngle -= 90; } //echo $imageAngle; $radAngle1 = $meridian1 * (M_PI / 180); $radAngle2 = $meridian2 * (M_PI / 180); $x1 = intval(cos($radAngle1) * ($halfCross + $gutter) + $halfCross) - 6; $y1 = intval(-(sin($radAngle1) * ($halfCross + $gutter)) + $halfCross + $gutter / 2); $x2 = intval(cos($radAngle2) * ($halfCross + $gutter) + $halfCross) - 6; $y2 = intval(-(sin($radAngle2) * ($halfCross + $gutter)) + $halfCross + $gutter / 2); $crossCSS = "width: " . $crossSize . "px; height: " . $crossSize . "px; margin:" . $gutter . "px"; $num1CSS = $labelCSS . "top: " . $y1 . "px; left: " . $x1 . "px; "; $num2CSS = $labelCSS . "top: " . $y2 . "px; left: " . $x2 . "px; "; $num1aCSS = $labelCSS . "bottom: " . ($y1 - $gutter / 2) . "px; right: " . $x1 . "px; "; $num2aCSS = $labelCSS . "bottom: " . ($y2 - $gutter / 2) . "px; right: " . $x2 . "px; "; $html .= "<img style='{$crossCSS}' src='" . $crossImage . $imageAngle . ".png" . "' />"; $html .= "<div class='cross_num1' style='{$num1CSS}' >" . $num1 . "</div>"; $html .= "<div class='cross_num2' style='{$num2CSS}' >" . $num2 . "</div>"; $html .= "<div class='cross_meridian1' style='{$num1aCSS}' >" . numToAxisString($meridian1) . "</div>"; $html .= "<div class='cross_meridian2' style='{$num2aCSS}' >" . numToAxisString($meridian2) . "</div>"; } // end toric lenses / crosses //add the labels, if wanted if (isset($niceString1)) { $css = "width: {$totalSize} px; text-align: center"; $html .= "<div class='opticalCrossLabel' style='{$css}'>" . $niceString1 . "</div>"; if (isset($niceString2)) { $html .= "<div class='opticalCrossLabel' style='{$css}'>" . $niceString2 . "</div>"; } } if ($doVertex == 1) { $html .= "<div class='opticalCrossLabel' style='{$css} ;font-size:smaller;opticalCrossLabel margin: .5em;'>(vertexed) </div>"; } $html .= "</div>"; return $html; }