Computes the point at which two lines intersect.

@return Point|null
960463
public static function intersection(
        ImagickRendererLine $l1,
        ImagickRendererLine $l2
    ) {
        $rs = $l1->rx * $l2->ry - $l1->ry * $l2->rx;

        if ($rs == 0) {
            return null;
        }
        
        $u = (($l2->Px - $l1->Px) * $l1->ry - ($l2->Py - $l1->Py) * $l1->rx) / $rs;

        return new Point(
            $l2->Px + $u * $l2->rx,
            $l2->Py + $u * $l2->ry
        );
    }
246636
Point2D intersect(Point2D a, Point2D b) {
        return intersect(pointsOf(hull), new Line2D.Double(a.getX(), a.getY(), b.getX(), b.getY()));
    }
1133537
public function center()
    {
        /* Determine the real center */
        $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
        $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;

        /* Get current boundaries */
        $XMin = $this->X2;
        $XMax = $this->X1;
        $YMin = $this->Y2;
        $YMax = $this->Y1;
        foreach ($this->Data as $Key => $Settings) {
            $X = $Settings["X"];
            $Y = $Settings["Y"];

            if ($X < $XMin) {
                $XMin = $X;
            }
            if ($X > $XMax) {
                $XMax = $X;
            }
            if ($Y < $YMin) {
                $YMin = $Y;
            }
            if ($Y > $YMax) {
                $YMax = $Y;
            }
        }
        $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin;
        $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin;

        /* Compute the offset to apply */
        $XOffset = $TargetCenterX - $CurrentCenterX;
        $YOffset = $TargetCenterY - $CurrentCenterY;

        /* Correct the points position */
        foreach ($this->Data as $Key => $Settings) {
            $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
            $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
        }
    }
956080
public function intersect()
    {
        $arrays = func_get_args();

        $arrays = array_map(function ($array) {
            return $this->getAvailableArray($array);
        }, $arrays);

        array_unshift($arrays, $this->all());

        $arrays = call_user_func_array('array_intersect', $arrays);

        return new static($arrays);
    }
895826
public static boolean intersect(long[] x, long[] y) {
    final int min = (x.length < y.length) ? x.length : y.length;
    for(int i = 0; i < min; i++) {
      if((x[i] & y[i]) != 0L) {
        return true;
      }
    }
    return false;
  }
138088
function (p, p1, maxIndex, minIndex) {
		var points = this._originalPoints,
			p2, p3;

		minIndex = minIndex || 0;

		// Check all previous line segments (beside the immediately previous) for intersections
		for (var j = maxIndex; j > minIndex; j--) {
			p2 = points[j - 1];
			p3 = points[j];

			if (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) {
				return true;
			}
		}

		return false;
	}
81599
function intersectLine (lineSegment1, lineSegment2) {
  const intersectionPoint = {};

  let x1 = lineSegment1.start.x,
    y1 = lineSegment1.start.y,
    x2 = lineSegment1.end.x,
    y2 = lineSegment1.end.y,
    x3 = lineSegment2.start.x,
    y3 = lineSegment2.start.y,
    x4 = lineSegment2.end.x,
    y4 = lineSegment2.end.y;

  // Coefficients of line equations
  let a1, a2, b1, b2, c1, c2;
  // Sign values
  let r1, r2, r3, r4;

  // Intermediate values
  let denom, num;

  // Compute a1, b1, c1, where line joining points 1 and 2 is "a1 x  +  b1 y  +  c1  =  0"
  a1 = y2 - y1;
  b1 = x1 - x2;
  c1 = x2 * y1 - x1 * y2;

  // Compute r3 and r4
  r3 = a1 * x3 + b1 * y3 + c1;
  r4 = a1 * x4 + b1 * y4 + c1;

  /* Check signs of r3 and r4.  If both point 3 and point 4 lie on
    * same side of line 1, the line segments do not intersect.
    */

  if (r3 !== 0 &&
        r4 !== 0 &&
        sign(r3) === sign(r4)) {
    return;
  }

  // Compute a2, b2, c2
  a2 = y4 - y3;
  b2 = x3 - x4;
  c2 = x4 * y3 - x3 * y4;

  // Compute r1 and r2
  r1 = a2 * x1 + b2 * y1 + c2;
  r2 = a2 * x2 + b2 * y2 + c2;

  /* Check signs of r1 and r2.  If both point 1 and point 2 lie
    * on same side of second line segment, the line segments do
    * not intersect.
    */

  if (r1 !== 0 &&
        r2 !== 0 &&
        sign(r1) === sign(r2)) {
    return;
  }

  /* Line segments intersect: compute intersection point.
    */

  denom = (a1 * b2) - (a2 * b1);

  /* The denom/2 is to get rounding instead of truncating.  It
    * is added or subtracted to the numerator, depending upon the
    * sign of the numerator.
    */

  num = (b1 * c2) - (b2 * c1);
  const x = parseFloat(num / denom);

  num = (a2 * c1) - (a1 * c2);
  const y = parseFloat(num / denom);

  intersectionPoint.x = x;
  intersectionPoint.y = y;

  return intersectionPoint;
}
596985
public function getPoints()
	{
		/** @var Point[] $points */
		$points = [];

		foreach ($this->segments as $segment) {
			$points = array_merge($points, $segment->points);
		}

		if (phpGPX::$SORT_BY_TIMESTAMP && !empty($points)) {
			usort($points, array('phpGPX\Helpers\DateTimeHelper', 'comparePointsByTimestamp'));
		}

		return $points;
	}
951450
public function getLineCoverage()
    {
        if ($this->lineCoverage === null) {
            $this->lineCoverage = $this->calculateLineCoverage($this->statements, $this->coveredStatements);
        }

        return $this->lineCoverage;
    }
1254369
public function getPrevious()
    {
        $pos = $this->getPosition();
        if ($pos == 0) {
            return null;
        } else {
            $this->getInternalIterator()->seek($pos - 1);

            return $this->getCurrent();
        }
    }
1008366
public function inside(QtiPoint $point)
    {
        if ($this->getShape() === QtiShape::DEF) {
            return true;
        } elseif ($this->getShape() === QtiShape::RECT) {
            return $point->getX() >= $this[0] && $point->getX() <= $this[2] && $point->getY() >= $this[1] && $point->getY() <= $this[3];
        } elseif ($this->getShape() === QtiShape::CIRCLE) {
            return pow($point->getX() - $this[0], 2) + pow($point->getY() - $this[1], 2) < pow($this[2], 2);
        } else {
            // we consider it is a polygon.
            // - Transform coordinates in vertices.
            // -- Use of the "point in polygon" algorithm.
            $vertices = array();
            for ($i = 0; $i < count($this); $i++) {
                $vertex = array();
                $vertex[] = $this[$i]; //x
                $i++;
                $vertex[] = $this[$i]; //y

                $vertices[] = $vertex;
            }

            $intersects = 0;
            for ($i = 1; $i < count($vertices); $i++) {
                $vertex1 = $vertices[$i -1];
                $vertex2 = $vertices[$i];

                if ($vertex1[1] === $vertex2[1] && $vertex1[1] === $point->getY() && $point->getX() > min($vertex1[0], $vertex2[0]) && $point->getX() < max($vertex1[0], $vertex2[0])) {
                    // we are on a boundary.
                    return true;
                }

                if ($point->getY() > min($vertex1[1], $vertex2[1]) && $point->getY() <= max($vertex1[1], $vertex2[1]) && $point->getX() <= max($vertex1[0], $vertex2[0]) && $vertex1[1] !== $vertex2[1]) {
                    $xinters = ($point->getY() - $vertex1[1]) * ($vertex2[0] - $vertex1[0]) / ($vertex2[1] - $vertex1[1]) + $vertex1[0];

                    if ($xinters === $point->getX()) {
                        // Again, we are on a boundary.
                        return true;
                    }

                    if ($vertex1[0] === $vertex2[0] || $point->getX() <= $xinters) {
                        // We have a single intersection.
                        $intersects++;
                    }
                }
            }

            // If we passed through an odd number of edges, we are in the polygon!
            return $intersects % 2 !== 0;
        }
    }
736207
private static Point getEllipseIntersection(Shape shape,
                                                Line2D.Double line) {
        double angle = Math.atan2(line.y2 - line.y1,
                                  line.x2 - line.x1);
        double x = shape.getBounds2D().getWidth() / 2 * Math.cos(angle) + shape.getBounds2D().getCenterX();
        double y = shape.getBounds2D().getHeight() / 2 * Math.sin(angle) + shape.getBounds2D().getCenterY();
        Point p = new Point();
        p.setLocation(x,
                      y);
        return p;
    }
468702
public Bbox intersection(Bbox other) {
		if (!this.intersects(other)) {
			return null;
		} else {
			double minx = other.getX() > this.getX() ? other.getX() : this.getX();
			double maxx = other.getEndPoint().getX() < this.getEndPoint().getX() ? other.getEndPoint().getX() : this
					.getEndPoint().getX();
			double miny = other.getY() > this.getY() ? other.getY() : this.getY();
			double maxy = other.getEndPoint().getY() < this.getEndPoint().getY() ? other.getEndPoint().getY() : this
					.getEndPoint().getY();
			return new Bbox(minx, miny, (maxx - minx), (maxy - miny));
		}
	}
1207165
public function peek()
	{
		if (isset ($this->data[$this->position + 1]))
		{
			return $this->data[$this->position + 1];
		}
		return null;
	}
1311136
public Vector2f intersect(Line other, boolean limit) {
		Vector2f temp = new Vector2f();

		if (!intersect(other, limit, temp)) {
			return null;
		}

		return temp;
	}
1089903
public boolean intersect(Line other, boolean limit, Vector2f result) {
		float dx1 = end.getX() - start.getX();
		float dx2 = other.end.getX() - other.start.getX();
		float dy1 = end.getY() - start.getY();
		float dy2 = other.end.getY() - other.start.getY();
		float denom = (dy2 * dx1) - (dx2 * dy1);

		if (denom == 0) {
			return false;
		}

		float ua = (dx2 * (start.getY() - other.start.getY()))
				- (dy2 * (start.getX() - other.start.getX()));
		ua /= denom;
		float ub = (dx1 * (start.getY() - other.start.getY()))
				- (dy1 * (start.getX() - other.start.getX()));
		ub /= denom;

		if ((limit) && ((ua < 0) || (ua > 1) || (ub < 0) || (ub > 1))) {
			return false;
		}

		float u = ua;

		float ix = start.getX() + (u * (end.getX() - start.getX()));
		float iy = start.getY() + (u * (end.getY() - start.getY()));

		result.set(ix, iy);
		return true;
	}
1325405
public double intersectY(double y)
	{
		if (direction.y == 0)
			return Double.NaN;
		return (y - origin.y) / direction.y;
	}