public function apply($resource) { return parent::apply($resource, parent::HORIZONTAL, 2, 1, 0, 0, 0); }
/** * @covers Classes\Utils\Math\Lines::getPointOnLineWithOffset */ public function testGetPointOnLineWithOffset_3() { $p1 = new \Classes\Utils\AbstractInstance\Point(1, 1, 1); $p2 = new \Classes\Utils\AbstractInstance\Point(5, 5, 5); $line = new \Classes\Utils\AbstractInstance\Line($p1, $p2); $offset = 2 * sqrt(3); $point = Lines::getPointOnLineWithOffset($line, $offset); $this->assertEquals($point->x, 3); $this->assertEquals($point->y, 3); $this->assertEquals($point->z, 3); }
/** * @return \Lib\Import\Line */ protected function parseLine() { return $this->importIterator->next(); }
public static function findOverlappingOfTwoLines($line1, $line2, &$overlap1, &$overlap2) { $isLine1Reversed = FALSE; // Check same line or not if (!Lines::isTwoPiecesOnSameLine($line1, $line2)) { return FALSE; } // Check same directions or not if (!Lines::areTwoVectorHaveSameDirection($line1, $line2)) { $line1->reverse(); $isLine1Reversed = TRUE; } // Points $point1 = $line1->point1; $point2 = $line1->point2; // Line 1 $point3 = $line2->point1; $point4 = $line2->point2; // Line 2 // Calculate line coordinates from point1 $x1 = 0; $x2 = Points::twoPointsDistance($point1, $point2); $x3 = Points::twoPointsDistance($point1, $point3); $x4 = Points::twoPointsDistance($point1, $point4); // Set sign to coordinates if (!Lines::areTwoVectorHaveSameDirection($line1, new \Classes\Utils\AbstractInstance\Line($point1, $point3))) { $x3 *= -1; } // Set sign to coordinates if (!Lines::areTwoVectorHaveSameDirection($line1, new \Classes\Utils\AbstractInstance\Line($point1, $point4))) { $x4 *= -1; } // Overlapping length $length = min($x2, $x4) - max($x1, $x3); // Check if therу is overlapping if ($length <= 0) { return FALSE; } // Create coordinate array $arrayToSort = array(0 => array('point' => 1, 'value' => $x1), 1 => array('point' => 2, 'value' => $x2), 2 => array('point' => 3, 'value' => $x3), 3 => array('point' => 4, 'value' => $x4)); $sortedArray = Constant::sortArrayByIndex($arrayToSort, 'value'); // Check variant of overlapping // 1-3-2-4 if ($sortedArray[0]['point'] == 1 && $sortedArray[1]['point'] == 3 && $sortedArray[2]['point'] == 2 && $sortedArray[3]['point'] == 4) { $overlap1 = array($x3, $x2); $overlap2 = array(0, $x2 - $x3); } // 3-1-4-2 if ($sortedArray[0]['point'] == 3 && $sortedArray[1]['point'] == 1 && $sortedArray[2]['point'] == 4 && $sortedArray[3]['point'] == 2) { $overlap1 = array(0, $x4); $overlap2 = array($x1 - $x3, $x4 - $x3); } // 1-3-4-2 if ($sortedArray[0]['point'] == 1 && $sortedArray[1]['point'] == 3 && $sortedArray[2]['point'] == 4 && $sortedArray[3]['point'] == 2) { $overlap1 = array($x3, $x4); $overlap2 = array(0, $x4 - $x3); } // 3-1-2-4 if ($sortedArray[0]['point'] == 3 && $sortedArray[1]['point'] == 1 && $sortedArray[2]['point'] == 2 && $sortedArray[3]['point'] == 4) { $overlap1 = array(0, $x2); $overlap2 = array($x1 - $x3, $x2 - $x3); } // Reverse overlapping of line1 if ($isLine1Reversed) { // $x2 = Length(line1) $begin = $x2 - $overlap1[1]; $end = $x2 - $overlap1[0]; $overlap1[0] = $begin; $overlap1[1] = $end; } return TRUE; }