本文整理汇总了PHP中Point::getY方法的典型用法代码示例。如果您正苦于以下问题:PHP Point::getY方法的具体用法?PHP Point::getY怎么用?PHP Point::getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point::getY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: contains
/**
* @param Point $point
* @return bool
*/
public function contains(Point $point)
{
$vertices = $this->points->getPoints();
// Check if the point is inside the polygon or on the boundary
$intersections = 0;
for ($i = 1; $i < $this->points->getPoints()->count(); $i++) {
$vertex1 = $vertices->offsetGet($i - 1);
$vertex2 = $vertices->offsetGet($i);
// Check if point is on an horizontal polygon boundary
if ($vertex1->getY() == $vertex2->getY() && $vertex1->getY() == $point->getY() && $point->getX() > min($vertex1->getX(), $vertex2->getX()) && $point->getX() < max($vertex1->getX(), $vertex2->getX())) {
return true;
}
if ($point->getY() > min($vertex1->getY(), $vertex2->getY()) && $point->getY() <= max($vertex1->getY(), $vertex2->getY()) && $point->getX() <= max($vertex1->getX(), $vertex2->getX()) and $vertex1->getY() != $vertex2->getY()) {
$xinters = ($point->getY() - $vertex1->getY()) * ($vertex2->getX() - $vertex1->getX()) / ($vertex2->getY() - $vertex1->getY()) + $vertex1->getX();
// Check if point is on the polygon boundary (other than horizontal)
if ($xinters == $point->getX()) {
return true;
}
if ($vertex1->getX() == $vertex2->getX() || $point->getX() <= $xinters) {
$intersections++;
}
}
}
// If the number of edges we passed through is odd, then it's in the polygon.
if ($intersections % 2 != 0) {
return true;
} else {
return false;
}
}
示例2: hasPoint
/**
* Return true if the given point is on the line
*
* @param Point $point
* @return bool
*/
public function hasPoint(Point $point)
{
$nv = $this->getNormalVector();
if ($nv->getX() * $point->getX() + $nv->getY() * $point->getY() != $nv->getX() * $this->a->getX() + $nv->getY() * $this->a->getY()) {
return false;
}
return $point->getX() >= $this->a->getX() && $point->getX() <= $this->b->getX() && $point->getY() >= $this->a->getY() && $point->getY() <= $this->b->getY();
}
示例3: __construct
public function __construct(Point $center, $edge_length)
{
$this->edge = $edge_length;
$this->minX = $center->getX() - $this->edge / 2;
$this->maxX = $center->getX() + $this->edge / 2;
$this->minY = $center->getY() - $this->edge / 2;
$this->maxY = $center->getY() + $this->edge / 2;
$this->minZ = $center->getZ() - $this->edge / 2;
$this->maxZ = $center->getZ() + $this->edge / 2;
}
示例4: testShouldAssignXYCoordinates
/**
* @covers Imagine\Image\Point::getX
* @covers Imagine\Image\Point::getY
* @covers Imagine\Image\Point::in
*
* @dataProvider getCoordinates
*
* @param integer $x
* @param integer $y
* @param BoxInterface $box
* @param Boolean $expected
*/
public function testShouldAssignXYCoordinates($x, $y, BoxInterface $box, $expected)
{
$coordinate = new Point($x, $y);
$this->assertEquals($x, $coordinate->getX());
$this->assertEquals($y, $coordinate->getY());
$this->assertEquals($expected, $coordinate->in($box));
}
示例5: testValidPoint
/**
* test using valid x, valid y
**/
public function testValidPoint()
{
$point = new Point($this->VALID_X, $this->VALID_Y);
//use the mutators to make a valid test case
$point->setX($this->VALID_X);
$point->setY($this->VALID_Y);
// assertSame() that getFoo() is the same as $VALID_FOO
$this->assertSame($point->getX(), $this->VALID_X);
$this->assertSame($point->getY(), $this->VALID_Y);
}
示例6: testGetValidSegmentByStopElevation
/**
* test grabbing a segment by SegmentStopElevation
**/
public function testGetValidSegmentByStopElevation()
{
//count the number of rows and save it for later
$numRows = $this->getConnection()->getRowCount("segment");
//create a new segment and insert it into the database
$segment = new Segment(null, $this->VALID_SEGMENTSTART, $this->VALID_SEGMENTSTOP, $this->VALID_SEGMENTSTARTELEVATION, $this->VALID_SEGMENTSTOPELEVATION);
$segment->insert($this->getPDO());
//grab the data from mySQL and verify the fields
$pdoSegments = Segment::getSegmentBySegmentStopElevation($this->getPDO(), $segment->getSegmentStopElevation());
$this->assertSame($numRows + 1, $this->getConnection()->getRowCount("segment"));
foreach ($pdoSegments as $pdoSegment) {
$this->assertSame($pdoSegment->getSegmentStart()->getX(), $this->VALID_SEGMENTSTART->getX());
$this->assertSame($pdoSegment->getSegmentStart()->getY(), $this->VALID_SEGMENTSTART->getY());
$this->assertSame($pdoSegment->getSegmentStop()->getX(), $this->VALID_SEGMENTSTOP->getX());
$this->assertSame($pdoSegment->getSegmentStop()->getY(), $this->VALID_SEGMENTSTOP->getY());
$this->assertSame($pdoSegment->getSegmentStartElevation(), $this->VALID_SEGMENTSTARTELEVATION);
$this->assertSame($pdoSegment->getSegmentStopElevation(), $this->VALID_SEGMENTSTOPELEVATION);
}
}
示例7: distance
public function distance(Point $p1, Point $p2)
{
$p1x = $p1->getX();
$p2x = $p2->getX();
$p1y = $p1->getY();
$p2y = $p2->getY();
$v1 = ($p1x - $p2x) * -1;
$v2 = ($p1y - $p2y) * -1;
$steps = $v1 + $v2;
$distance = sqrt($v1 * $v1 + $v2 * $v2);
return $distance;
}
示例8: getSegmentBySegmentStop
/**
* gets segment by segmentStop
*
* @param PDO $pdo pointer to PDO connection
* @param Point $segmentStop stop point to trail-search for
* @return mixed segment found or null if not found
* @throws PDOException when mySQL related errors occur
* @throws RangeException when range is invalid
* @throws Exception for other exception
*/
public static function getSegmentBySegmentStop(PDO &$pdo, Point $segmentStop)
{
//create query template
$query = "SELECT segmentId, ST_AsWKT(segmentStart) AS segmentStart, ST_AsWKT(segmentStop) AS segmentStop, segmentStartElevation, segmentStopElevation FROM segment WHERE segmentStop = POINT(:segmentStopX, :segmentStopY)";
$statement = $pdo->prepare($query);
//binds segmentStop to placeholder
$parameters = array("segmentStopX" => $segmentStop->getX(), "segmentStopY" => $segmentStop->getY());
$statement->execute($parameters);
//build an array of segments
$segments = new SplFixedArray($statement->rowCount());
$statement->setFetchMode(PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$segmentStartJSON = Gisconverter::wktToGeojson($row["segmentStart"]);
$segmentStopJSON = Gisconverter::wktToGeojson($row["segmentStop"]);
$segmentStartGenericObject = json_decode($segmentStartJSON);
$segmentStopGenericObject = json_decode($segmentStopJSON);
$segmentStart = new Point($segmentStartGenericObject->coordinates[0], $segmentStartGenericObject->coordinates[1]);
$segmentStop = new Point($segmentStopGenericObject->coordinates[0], $segmentStopGenericObject->coordinates[1]);
$segment = new Segment($row["segmentId"], $segmentStart, $segmentStop, $row["segmentStartElevation"], $row["segmentStopElevation"]);
$segments[$segments->key()] = $segment;
$segments->next();
} catch (Exception $e) {
//if the row couldn't be converter, rethrow it
throw new PDOException($e->getMessage(), 0, $e);
}
}
return $segments;
}
示例9: equals
/**
* @param Point $point
*
* @return bool
*/
public function equals(Point $point)
{
return $point->getX() == $this->x && $point->getY() == $this->y;
}
示例10: drawGradient
private function drawGradient(Point $point1, Point $point2, Color $color, $decay)
{
/* Positive gradient */
if ($decay > 0) {
$YStep = ($point2->getY() - $point1->getY() - 2) / $decay;
for ($i = 0; $i <= $decay; $i++) {
$color = $color->addRGBIncrement(-1);
$Yi1 = $point1->getY() + $i * $YStep;
$Yi2 = ceil($Yi1 + $i * $YStep + $YStep);
if ($Yi2 >= $Yi2) {
$Yi2 = $point2->getY() - 1;
}
$this->canvas->drawFilledRectangle(new Point($point1->getX(), $Yi1), new Point($point2->getX(), $Yi2), $color, ShadowProperties::NoShadow());
}
}
/* Negative gradient */
if ($decay < 0) {
$YStep = ($point2->getY() - $point1->getY() - 2) / -$decay;
$Yi1 = $point1->getY();
$Yi2 = $point1->getY() + $YStep;
for ($i = -$decay; $i >= 0; $i--) {
$color = $color->addRGBIncrement(1);
$this->canvas->drawFilledRectangle(new Point($point1->getX(), $Yi1), new Point($point2->getX(), $Yi2), $color, ShadowProperties::NoShadow());
$Yi1 += $YStep;
$Yi2 += $YStep;
if ($Yi2 >= $Yi2) {
$Yi2 = $point2->getY() - 1;
}
}
}
}
示例11: drawFilledCircle
public function drawFilledCircle(Point $center, $height, Color $color, ShadowProperties $shadowProperties, $width = null)
{
if ($width == null) {
$width = $height;
}
$C_Circle = $this->allocateColor($color);
$Step = 360 / (2 * M_PI * max($width, $height));
for ($i = 90; $i <= 270; $i = $i + $Step) {
$X1 = cos($i * M_PI / 180) * $height + $center->getX();
$Y1 = sin($i * M_PI / 180) * $width + $center->getY();
$X2 = cos((180 - $i) * M_PI / 180) * $height + $center->getX();
$Y2 = sin((180 - $i) * M_PI / 180) * $width + $center->getY();
$this->drawAntialiasPixel(new Point($X1 - 1, $Y1 - 1), $color, $shadowProperties);
$this->drawAntialiasPixel(new Point($X2 - 1, $Y2 - 1), $color, $shadowProperties);
if ($Y1 - 1 > $center->getY() - max($width, $height)) {
imageline($this->picture, $X1, $Y1 - 1, $X2 - 1, $Y2 - 1, $C_Circle);
}
}
}
示例12: subtract
/**
*
* Вычитает из высоты и ширины размера координаты точки или
* высоту и ширину другого размера и возвращает получившийся размер.
*
* @param Size $s
* @param Size|Point $obj
* @return Size
* @throws IllegalArgumentException
*/
public static function subtract(Size $s, $obj)
{
if ($obj instanceof Size) {
return new Size($s->getWidth() - $obj->getWidth(), $s->getHeight() - $obj->getHeight());
} else {
if ($obj instanceof Point) {
return new Size($s->getWidth() - $obj->getX(), $s->getHeigth() - $obj->getY());
}
}
throw new IllegalArgumentException();
}
示例13: circle
public function circle(Point $a, $r)
{
$xc = $a->getX();
$yc = $a->getY();
$x = 0;
$y = $r;
$d = $r - 1;
while ($y >= $x) {
$this->moveCursorTo($xc + $x, $yc + $y);
echo "@";
$this->moveCursorTo($xc + $y, $yc + $x);
echo "@";
$this->moveCursorTo($xc - $x, $yc + $y);
echo "@";
$this->moveCursorTo($xc - $y, $yc + $x);
echo "@";
$this->moveCursorTo($xc + $x, $yc - $y);
echo "@";
$this->moveCursorTo($xc + $y, $yc - $x);
echo "@";
$this->moveCursorTo($xc - $x, $yc - $y);
echo "@";
$this->moveCursorTo($xc - $y, $yc - $x);
echo "@";
if ($d >= 2 * $x) {
$d -= 2 * $x + 1;
$x++;
} else {
if ($d < 2 * ($r - $y)) {
$d += 2 * $y - 1;
$y--;
} else {
$d += 2 * ($y - $x - 1);
$y--;
$x++;
}
}
}
}
示例14: Point
$rectangleArea = $firstSide * $secondSide;
echo 'Rectangle area: ' . $rectangleArea;
?>
</div>
</section>
<section class="panel panel-info top-buffer">
<header class="panel-heading">
<h2>Problem 4. Triangle Area</h2>
</header>
<div class="panel-body">
<?php
$pointA = new Point(-5, 10);
$pointB = new Point(25, 30);
$pointC = new Point(60, 15);
$area = abs(($pointA->getX() * ($pointB->getY() - $pointC->getY()) + $pointB->getX() * ($pointC->getY() - $pointA->getY()) + $pointC->getX() * ($pointA->getY() - $pointB->getY())) / 2);
echo 'The area is: ' . $area;
?>
</div>
</section>
<section class="panel panel-info top-buffer">
<header class="panel-heading">
<h2>Problem 5. Boolean Variable</h2>
</header>
<div class="panel-body">
<?php
$isFemale = false;
echo "I'm female? - " . getBooleanDisplayValue($isFemale);
?>
</div>
示例15: equals
/**
* Сравнивает две точки
*
* @param Point
* @return boolean
*/
public function equals(Point $p)
{
return $this->getX() == $p->getX() && $this->getY() == $p->getY();
}