1 Introduction

Currently, people have to deal with numerous data, whereas there is no interest in storing such massive data and, when it is necessary, there is no capability of storing. For example, consider the electronic portable devices such as smart phones, tablets, and other similar devices. If the GPS of a device is activated, the information related to the geographical coordinate is calculated at each moment. Does the moment-by-moment information, however, need to be stored on the device? Even if there is such a demand, is it possible to do it? The answer is negative. This is not possible due to the tremendous volume of existing data, and mostly, the information does not even need to be stored. Recall the above example; if a device is expected to keep the traveled path, it is not necessary to store the location coordinates at all moments. A smart algorithm can evaluate received coordinates of all points, determine only those points where a redirection occurs, and store them in the memory.

Regarding the importance of this topic, various algorithms in limited memory models have already been suggested for different problems. On the other hand, computing the visibility polygon from a point inside the polygon is one of the most well-known problems in computational geometry and many results have been achieved on its time complexity in different conditions.

In this article, we propose a method to compute the visibility polygon from a point inside a polygon through a well-known limited memory model, called the multi-pass model. The rest of this paper is followed by a description of limited memory models and their characteristics and restrictions. Then, a review of other published researches about limited memory models and, in particular, the read-only model are presented. Finally, an algorithm is described and analyzed to solve this problem in a multi-pass model.

1.1 Problem statement and motivation

The problem can be posed more practically: There are a simple polygon, an observation center inside the polygon, and a mobile robot. This robot can move counterclockwise on the boundary of a polygon by linear segments and determines the coordinates of points where it changes its direction. The memory size of this robot is of less complexity compared to the given number of polygon vertices. Regarding the memory limitation, this robot should report all point coordinates of its path which is observed by the observation center. In this problem, the coordinate of the observation center is an input for the robot. To calculate the coordinates, the robot surveys the entire polygon’s boundary and afterward, it can also repeat the survey again. Since the number of vertices of the polygon is high, the number of this circulation on the polygon’s boundary should have less complexity than the number of polygon vertices.

As a result, the robot should report coordinates of two sets of its path points in the counterclockwise direction:

  1. (i)

    Vertices of the polygon which are observed by the observation center.

  2. (ii)

    The coordinate of the first and last points visible to the observation center from edges which are partially observed by the observation center and are not polygon vertices.

2 Types of limited memory models and results in these models

Due to restrictions in using memories, different models with versatile properties have been created and each one limits the memory usage for algorithms in a certain way. Here, we introduce three memory models including read-only, multi-pass, and the streaming data memory model and explain limitations of each model.

2.1 Read-only memory model

One of the first limited memory models which are used in the algorithm design is the read-only memory model. In this model, inputs are assumed to be located in a read-only memory. In problems addressed in this model, as evident from its name, writing in the memory which holds the information is not possible. Moreover, it should be noted that the size of workspace in this model cannot have linear complexity of the input size. This restriction is mostly due to the numerous data or used resources (or both). In problems studied through this model, if the input size is n, the amount of used memory is constant or in the order of \(O(\log n)\).

In order to know more about this model, the reader is referred to the in-place algorithms. In these algorithms, in addition to the memory where data are held, only a constant amount of extra memory is used. However, the difference between this model and others is that data are stored as read-only in this model and overwriting them is not possible.

The key point in the read-only model is that although it is not possible to write in the memory in which input data were located and the extra memory is also limited, all input data are available at the whole running time and one can have random access to input data at each moment. In the two following limited memory models, we will see that the method to access input data can also impose new limitations on the problem.

In this model of limited memory, for the problem of computing the visibility polygon, which is a well-known problem in computational geometry, Luis Barba et al. presented two algorithms to compute the visibility polygon of a point inside a polygon in this model; one of them uses constant extra memory and has \(O(n{\overline{r}})\) time complexity, in which \({\overline{r}}\) is the number of reflex vertices of output, and another uses \(O(\log r)\) extra memory and has \(O(n \log ^{2}r)\) time complexity for a deterministic algorithm or \(O(n \log r)\) time complexity for a randomized algorithm, where r is the number of reflex vertices of input polygon (Barba et al. 2011).

2.2 Multi-pass memory model

Another limited memory model by which some computational geometry problems have been assessed is the multi-pass model. This model is very similar to the read-only model in this aspect that in the multi-pass model, input data are also stored in a read-only memory and, additionally, there is a limited extra memory available to the algorithm. Similar to the previous model, the amount of this memory is lower than the order of inputs and is usually constant or proportional to the logarithm of the input size.

However, the main difference between these two models is the possibility to randomly access input data of the problem; the read-only model benefits from this feature, while in the multi-pass model, this accessibility is not possible and data can only be read in their localization order. Nevertheless, it is still possible to read data any time so that after reading the last data, they can be read from the first point. Thus, the number of data path-through and reading iteration is added as a new parameter to problems which are evaluated by this model.

In this model, Timothy Chan and Eric Chen proposed several algorithms to solve the convex hull problem and also the linear programming problem (Chan and Chen 2007).

2.3 Streaming data mode

In the two models described above, data can be read repetitively and only the extra memory was limited. However, we encounter more restrictions in the streaming data model. In this model, data are supposed to stream in a line and each data can be read only at the moment and, afterward, they will not be accessible. Also in this model, it is assumed that the memory used in the algorithm cannot be in the order of the number of inputs and such a memory is not available. An algorithm in this model should read the data stream on the data line in each step and at that moment, do the required processing, and then, decide which data or information should be stored in the memory. The amount of memory in this model is mostly presumed constant relative to input data or in the logarithmic order of input data.

Fig. 1
figure 1

(Left) Reflex vertices with respect to q are displayed by white points and others are displayed by black points. (Right) Visibility polygon \(\hbox {Vis}_{\mathcal {P}} (q)\); p is the shadow of vertex \(v_5\)

It is important to recall that only an approximation of the optimal solution is obtained for most non-trivial problems due to higher restrictions in this model. The reason is that each data can be read only once and not all of them can be stored. Hence, solving problems in this model is highly associated with approximate algorithms.

Hamid Zarabizadeh and Timothy Chan presented an approximation algorithm for computing the minimum enclosing ball of a point set in \({\mathcal {R}}^2\) in this model with constant extra memory, linear time complexity, and approximation factor of 3 / 2 (Zarrabi-Zadeh and Chan 2006).

3 Definitions and preliminaries

In this problem, vertices of a polygon are given in the multi-pass model as inputs in a counterclockwise order. This polygon and its boundary are denoted by \({\mathcal {P}}\) and \(\partial {\mathcal {P}}\), respectively. Likewise, a point like q is given as an input from which the visibility polygon should be computed. The segment connecting p and q is denoted by \({\overline{pq}}\). The \(p\in {\mathcal {P}}\) is a visible point from q if and only if \({\overline{pq}}\subset {\mathcal {P}}\). The set of all visible points from q in the polygon \({\mathcal {P}}\) is called visibility polygon and is symbolized by \(\hbox {Vis}_{\mathcal {P}} (q)\). It can be seen that the visibility polygon of the point q is a closed polygon whose vertices are either vertices of \({\mathcal {P}}\) or points of intersected edges of \({\mathcal {P}}\) with a shot ray from q which passes a reflex vertex of \({\mathcal {P}}\). Figure 1 shows this observation.

For simplicity, we assume that no line passes q and two vertices of \({\mathcal {P}}\) simultaneously. However, the proposed algorithm can well account for this condition with a minor modification.

Vertex \(v_k\) is a reflex vertex if the internal angle of this vertex in \({\mathcal {P}}\) is larger than \(\pi \). Given the vertex \(v_k\), line \(l_k\) which passes \(v_k\) and q separates \({\mathcal {R}}^2{\setminus } l_k\) into two components. Vertex \(v_k\) is a reflex vertex with respect to point q if this vertex is reflex, and \(v_{k-1}\) and \(v_{k+1}\) are in the same component of \({\mathcal {R}}^2{\setminus } l_k\). Paying attention to Fig. 1, each reflex vertex with respect to q is a reflex vertex, but the opposite is not correct.

In other words, reflex vertices with respect to q are those in which the state of the visibility polygon may change, i.e., positions where the polygon’s boundary can switch between visibility and invisibility. Since vertex q is a constant input, from now on, we avoid the term with respect to q and call these vertices simply as reflex vertices. The number of reflex vertices of \({\mathcal {P}}\) is denoted by r. Also the number of reflex vertices existing in \(\hbox {Vis}_{\mathcal {P}} (q)\) is denoted by \({\overline{r}}\). It is evident that \({\overline{r}}\le r<n\).

For any two points like \(p_i, p_j \in \partial {\mathcal {P}}\), there is a unique path which travels the \({\mathcal {P}}\) boundary from \(p_i\) to \(p_j\) in a counterclockwise direction. The set of passed points in this path including \(p_i\) and \(p_j\) is denoted by \(C_{i,j}\) and is called a chain between \(p_i\) and \(p_j\). A chain is said to be visible if all points of the chain are visible from the point q.

A visible chain such as \(C=C_{i,j}\) is CCW-maximal (counterclockwise-maximal) if it is visible and also no other visible chain started from \(p_i\) encloses the whole C. We will use \(C_{i,i}\) to refer to the entire polygon’s boundary.

For a point \(p \in {\mathcal {P}}\), the angle which appears between the positive x axis and the ray shot from q and passes through p is denoted by \(\theta (p)\). We define \(\theta (p)\) in the range of \([0,2\pi )\). We consider \(v_0\) as the nearest point from \(\partial {\mathcal {P}}\) relative to q so that \(\theta (v_0 )=0\). It is obvious that \(v_0\) is visible and can be computed in a linear time. Without loss of generality, we assume \(v_0\) is a vertex of a polygon. Moreover, we assume that vertices of a polygon are numerated so that \(v_0\) is placed on the \(v_n v_1\) edge.

The point p on the \(\partial {\mathcal {P}}\) is called a shadow of a reflex vertex v if p, q, and v are collinear as well as point p is the first intersection between \(\partial {\mathcal {P}}\) and the shot ray from q and passing v. Based on the general location condition, v must be unique and p must be an internal point of an edge. Therefore, each reflex vertex is connected one by one to a shadow point and vice versa.

Here, we use the ray shooting operators and display it by \({ RayShooting}(p)\). This is an operator which takes a point \(p \in \partial {\mathcal {P}}\), calculates the ray \(\rho (q,p)\), and reports the first point of \(\partial {\mathcal {P}}\) which intersects this ray. This operator can be implemented in linear time so that all edges of \({\mathcal {P}}\) are checked one by one and the nearest intersection point to q is reported. Another similar operator which has been used here computes the shadow of such a reflex vertex as v. For this purpose, we use \({ FindShadow}(p)\). If p is a reflex vertex, this function will return the shadow of the vertex and, otherwise, the p itself.

If the chain \(C_{i,j}\) contains t reflex vertices, we display these vertices by \(r_{i,j,1}\) to \(r_{i,j,t}\), respectively, based on the order of observation on the chain. Hence, \(r_{i,j,k}\) indicates the kth reflex vertex of \(C_{i,j}\) according to the order of occurrence in this chain of the polygon. The half-line ending at q and passing through \(r_{i,j,k}\) is also denoted by \(\overrightarrow{qr_{i,j,k}}\).

4 Visibility polygon in multi-pass model

As mentioned in Sect. 2, Barba et al. (2011) proposed algorithms to solve visibility polygon problems in the limited memory read-only model. In their paper, two results have been presented for this problem. One uses O(1) variables within the time of \(O(n{\overline{r}})\), and another employs \(O(\log r)\) variables within the time of \(O(n \log r)\).

There is also another result in Bahoo et al. (2016). Bahoo et al. presented an algorithm to compute k-visibility region of a point in the read-only model using O(s) extra memory and \(O(n^2/s + n \log s)\) time complexity, where k is the highest number of walls the viewpoint can see behind.

The constant work space algorithm of Barba et al. (2011) can also be implemented in the multi-pass model because it does not need to have random access to input data. Another algorithm of Barba et al. (2011) which uses \(O(\log r)\) memory, however, cannot be used through the multi-pass model due to the need of random access to input data. In this section, we introduce a space–time trade-off algorithm.

The main idea to find the solution is to break the polygon boundary into chains which have t reflex vertices with respect to q. In each step, a part of that chain which is visible is calculated and reported until the entire polygon is processed.

At the beginning of the algorithm, we pass through input points to reach the first reflex vertex. From this point, we select the first chain including t reflex vertices. As previously mentioned, if a chain starts from vertex i and ends with vertex j, it is called \(C_{i,j}\) and the rest of the polygon is denoted by \(C_{j,i}\). Due to the memory restriction, only reflex vertices of this chain are stored in the memory. Here, we store the vertex number and coordinate for each vertex. We represent these vertices by \(r_{i,j,1}\) and \(r_{i,j,t}\), based on the observation order on the chain. Then, \(r_{i,j,k}\) indicates the kth reflex vertex of \(C_{i,j}\) by the occurrence order on this chain of the polygon.

While selecting this chain, we keep a minimal range of angle relative to q that contains the entire chain. Having the starting and ending points of an edge in the chain, the angle range relative to point q, in which the edge is located, can be specifically calculated. Thus, it is possible to calculate this angle range for \(C_{i,j}\). Going along this angle range, we can find out if the selected chain is placed in an angle range less than \(2\pi \) relative to the view point of q. It is necessary to know this for the next steps of the algorithm.

After these computations and according to the model limitations, we pass over other input data related to vertices of \(C_{j,i}\) to reach the vertex \(p_i\) once more. In this step, we calculate the shadow of all t reflex vertices of this chain by passing through \(C_{i,j}\). To achieve this purpose, for each edge, e, from the chain, all half-lines within \(\overrightarrow{qr_{i,j,k}}, 1\le k\le t\), which intersected at e are calculated. If the half-line and e cut across, we name the intersection as x. When the distance x from q is shorter than the distance between \(r_{i,j,k}\) and q, we set \(\mathrm{shadow}_{i,j}(r_{i,j,k})\) to \(\mathrm{NIL}\). In other words, this reflex vertex is not visible from point q via the chain \(C_{i,j}\). However, if the distance between x and q is larger than the distance between \(r_{i,j,k}\) and q and also less than the current distance between \(\mathrm{shadow}_{i,j}(r_{i,j,k})\) and q, we set the value of \(\mathrm{shadow}_{i,j}(r_{i,j,k})\) to x. By passing through \(C_{i,j}\) and repeating this operation for each edge, regardless of the \(C_{i,j}\), the shadow of each visible reflex vertex of this chain is finally obtained. The shadow of invisible vertices is also represented by NIL.

However, some of the reflex vertices of \(C_{i,j}\) may be visible from q, but do not have any shadow on this chain. These vertices can also be determined by setting the initial value of the shadow related to all reflex vertices to \(\infty \) before starting this step.

Fig. 2
figure 2

(Left) Case 1: \(C_{i,j}\) turned less than \(2\pi \) around q. (Right) Case 2: \(C_{i,j}\) turned (equal or) more than \(2\pi \) around q

In the following, by passing through input data of \(C_{j,i}\), the aim would be to calculate which half-lines among \(\overrightarrow{qr_{i,j,k}}\) cut across edges of \(C_{j,i}\), for all \(r_{i,j,k}\) so that \(\mathrm{shadow}_{i,j}(r_{i,j,k})\ne \hbox {NIL}\), and which do not cut. To do so, before starting to pass through \(C_{j,i}\), a copy of all reflex vertices in \(C_{i,j}\) which are not blocked via this chain is placed in a circular doubly linked list in the same order that occurred on the polygon. Since some vertices \(r_{i,j,1}\) to \(r_{i,j,t}\) may not be in this list, vertices of this list are displayed by \(r'_{i,j,1}\) to \(r'_{i,j,t'}\), in polygonal order. It is obvious that \(t' \le t\). Thus, \(r'_{i,j,k}\) indicates the kth reflex vertex of \(C_{i,j}\) whose view has not been blocked by \(C_{i,j}\).

Therefore, we state two lemmas.

Lemma 1

The chain \(C_{j,i}\) starting from point \(p_j\) either does not intersect any half-lines \(\overrightarrow{qr'_{i,j,1}}\) to \(\overrightarrow{qr'_{i,j,t'}}\) or the first half-line at which the chain intersects is \(\overrightarrow{qr'_{i,j,1}}\) or \(\overrightarrow{qr'_{i,j,t'}}\).

Proof

\(C_{j,i}\) may not intersect at any of the mentioned half-lines. But if the chain intersects at one of these half-lines and the first intersection next to point \(p_j\) is not one of two half-lines \(\overrightarrow{qr'_{i,j,1}}\) or \(\overrightarrow{qr'_{i,j,t'}}\), the order of visibility of the chain, starting \(p_i\) to the intersection point from viewpoint q, is violated. Since we know that the order of vertices in the visibility polygon is essentially according to the occurrence sequence on the main polygon, this is not possible. \(\square \)

Lemma 2

If \(C_{j,i}\) intersects at \(\overrightarrow{qr'_{i,j,k}}\) in the counterclockwise direction, afterward, it can just intersect at this half-line in a clockwise direction or at \(\overrightarrow{qr'_{i,j,k+1}}\) in the counterclockwise direction. Similarly, if \(C_{j,i}\) intersects at \(\overrightarrow{qr'_{i,j,k}}\) in the clockwise direction, afterward, it can just intersect at this half-line in a counterclockwise direction or at \(\overrightarrow{qr'_{i,j,k-1}}\) in the clockwise direction.

Proof

Half-lines \(\overrightarrow{qr'_{i,j,k}}\), \(\overrightarrow{qr'_{i,j,k+1}}\) (or \(\overrightarrow{qr'_{i,j,k-1}}\)) and the chain between \(r'_{i,j,k}\) and \(r'_{i,j,k+1}\) (or \(r'_{i,j,k-1}\)) constitute a closed polygon. Therefore, regarding the simplicity of a polygon, each edge which enters this polygon has no way to exit but pass these two half-lines. \(\square \)

As implied in above two lemmas, to find the list of desired reflex vertices, we keep surveying data input until an edge of \(C_{j,i}\) intersects one of two half-lines \(\overrightarrow{qr'_{i,j,1}}\) or \(\overrightarrow{qr'_{i,j,t'}}\). According to Lemma 1, we know that if none of these half-lines are not intersected, no other reflex point of \(C_{i,j}\) can be blocked via \(C_{i,j}\). Whenever an edge of \(C_{j,i}\) intersects one of \(\overrightarrow{qr'_{i,j,1}}\) or \(\overrightarrow{qr'_{i,j,t'}}\), we remove that reflex point from the linked list of reflex vertices. Then, by removing the vertex whose view is blocked in this step, we have two half-line candidates for intersecting at the rest of the polygon which are previous and next points of the vertex before removing. These steps continue until reaching the vertex \(p_i\).

To reach this linked list, we started from the list of all reflex vertices of \(C_{i,j}\) and in two steps removed those vertices whose view is blocked via the own \(C_{i,j}\) and then removed those vertices whose view is blocked by \(C_{j,i}\). Therefore, at the end of this step, in this linked list, we have a list of all reflex vertices of \(C_{i,j}\) which are visible from q in the input polygon.

Based on how \(C_{i,j}\) turned around viewpoint q, there would be two cases; case 1 is the case that \(C_{i,j}\) turned less than \(2\pi \) around q, and case 2 is the case that \(C_{i,j}\) turned equal or more than \(2\pi \) around q. Figure 2 describes these two cases.

Visibility of \(C_{i,j}\) from q will be restricted to a wedge by \(C_{j,i}\). In order to report the visible part of \(C_{i,j}\), we should compute visible reflex vertices of this chain, and also the first and last visible points of \(C_{i,j}\). In case 1, in which \(C_{i,j}\) is turned less than \(2\pi \) around q, if visible reflex vertices of \(C_{i,j}\) are \(r'_{i,j,l}\) to \(r'_{i,j,m}\) for \(1\le l\le m\le t'\), then the first visible point of \(C_{i,j}\) will be between \(r'_{i,j,l-1}\) and \(r'_{i,j,l}\). Consequently, the last visible point of the chain will also be between vertices of \(r'_{i,j,m}\) and \(r'_{i,j,m+1}\). For \(l = 1\), the first visible point of \(C_{i,j}\) is vertex \(r'_{i,j,1}\) or its shadow on the same chain. Also if m is equal to \(t'\), the last visible point of \(C_{i,j}\) chain is vertex \(r'_{i,j,t'}\) or its shadow on the same chain.

Fig. 3
figure 3

(Left) The first visible point of the chain is between the first reflex vertex of \(C_{i,j}\) before \(r'_{i,j,1}\) and the vertex itself. (Right) The last visible point of the chain is a point between \(r'_{i,j,t'}\) and the first reflex vertex after this vertex on \(C_{i,j}\)

Lemma 3

For any two consequent reflex vertices \(r'_{i,j,k}\) and \(r'_{i,j,k+1}\), by having shadows of these two vertices on \(C_{i,j}\), it can be found which part of the chain between these two vertices is visible, by a constant number of passes through all input data.

Proof

Having two reflex vertices and their shadows on \(C_{i,j}\), we can obtain the angle range of which view is blocked by checking the intersection of polygon’s edges at half-lines connecting q and these two reflex vertices as well as these two vertices and their shadows (if any). Given the angle range and passing through the input data once, we can also find the first intersection of the chain between these two vertices at the shooting radius of q at these angles, which represents the starting and ending visible points of the chain. \(\square \)

Up to here we showed that in case 1, in which \(C_{i,j}\) is turned around the view point q less than \(2\pi \) and calculation of the first and last visible points of the chain is needed, according to Lemma 3, we can determine these two points of the chain after the previous steps, by constant passing on the input data.

In case 2, in which \(C_{i,j}\) is turned around view point q more than \(2\pi \), an extra step will be necessary. If reflex vertices \(r'_{i,j,1}\) and \(r'_{i,j,t'}\) are not visible from q, the situation is as case 1. Nevertheless, in case 1, if these vertices are visible, the first and last visible points of this chain are these two vertices. However, if the chain is turned around q more than \(2\pi \), those points are not the same anymore. In the former case, the first visible point will be between the last reflex vertex of \(C_{i,j}\) before \(r'_{i,j,1}\) and \(r'_{i,j,1}\). Likewise, the ending point of the visible part of the chain will be a point between \(r'_{i,j,t'}\) and the first reflex vertex after this vertex on \(C_{i,j}\). See Fig. 3.

Also in this case, both the first and the last visible points can be calculated by passing through the data once by checking all shadows of reflex vertices of \(C_{i,j}\) and maintaining the first and last of these shadows, respectively, for finding the first and last visible points of this chain and comparing them with \(r'_{i,j,1}\) and \(r'_{i,j,t'}\) in polygonal order.

Theorem 1

Given a setting of visible reflex vertices of a chain like \(C_{i,j}\) and the first and last visible points of this chain, we can report a part of the visibility polygon belonging to this chain by passing through the data once.

Proof

Reporting this part of the visibility polygon can be initiated from the starting point of this chain and is followed by reporting all vertices as far as a reflex vertex or a shadow of a reflex vertex is reached. If a reflex vertex is faced, chain reporting is continued by the shadow of the vertex on the chain. If a reflex vertex is seen after its shadow, we stop reporting after the shadow until we reach the reflex vertex and from there we will proceed with reporting vertices. The polygonal order of these visible reflex vertices and their shadows on the chain plays a key role in the correct reporting of these vertices. \(\square \)

All the steps which should be done in order to report the vertices of visibility polygon are summarized in Algorithm 1.

Theorem 2

A visibility polygon of a polygon with n vertices in a multi-pass model can be calculated using O(t) extra variables within the time of \(O(nr/t+nt)\) where r indicates the number of reflex vertices of the polygon and t is between 2 and r.

Proof

To report the visibility polygon in a multi-pass model, one should apply the described procedure for one chain to consecutive chains including t reflex vertices until reaching the first reflex vertex. Also, one should report a part of each chain which appears in the visibility polygon in each step.

We know that the order of vertices of the visibility polygon is the same as the occurrence order in the input polygon. Thus, in this way, the polygon is correctly reported. On the other hand, we use O(t) variables in each step and at the end of this step we empty the memory so that this space can be used for the next chain. Hence, the number of total extra variables used in this algorithm is O(t).

In each step of the algorithm, a chain with t reflex vertices is selected. Although the reflex vertex at the end of each reflex chain would be the first reflex vertex of the next chain, still, the total number of repetitions is O(r / t). In each step, to observe the visible part of a chain like \(C_{i,j}\), a constant number of passes through the data are performed in all parts except one, and a number of constant operations are done for each data. O(t) time is spent for each edge of chain when one intends to find the shadow of t reflex vertices of the chain for each edge. This time is \(O(|C_{i,j}|t)\) for each chain. Although we limited only the number of reflex vertices of a chain and the length of each chain can be \(\theta (n)\), the key point in this analysis is that the sum of the entire chain lengths is also n.

In fact, the time complexity for running these chains is as follows:

$$\begin{aligned}&\mathop \sum \nolimits _{k=1}^{\lceil r/(t-1) \rceil }(n+ |C_{i_k,j_k}|t) \\&\quad =\mathop \sum \nolimits _{k=1}^{\lceil r/(t-1) \rceil }n+t \mathop \sum \nolimits _{k=1}^{\lceil r/(t-1) \rceil }|C_{i_k,j_k}| \\&\quad =O(nr/t+nt) \end{aligned}$$

\(\square \)

4.1 Observation

By choosing \(t = \sqrt{r}\), the time complexity would be \(O(n\sqrt{r})\) and it is the best running time complexity which can achieved by our algorithm.

figure a

As mentioned before, the best known algorithm to calculate the visibility polygon in the multi-pass model is through using a constant number of variables within the time of \(O(n{\overline{r}})\). It is not possible to decrease the running time of the algorithm by increasing the number of used variables. Here, however, we presented an algorithm which is able to reduce the running time via increasing the number of used variables. For example, if t is assumed to be \(\log r\), the running time of this algorithm approaches \(O(nr/\log r)\). Generally speaking, if t is in \(O(\sqrt{r})\), the time complexity becomes O(nr / t). On the other hand, we know that this condition is not improbable for t because less space is usually available in limited memory models.

5 Conclusion and future works

We presented an algorithm to compute the visibility polygon of a simple polygon from a viewpoint, inside it, in \(O(nr/t+nt)\) time using O(t) additional variables, where n is the size of input polygon and r is the number of its reflex vertices. Our suggestion to improve the results is to make the algorithm output sensitive. Considering parameter r in the time complexity and changing it to \({\overline{r}}\) can be a notable improvement for this problem, where \({\overline{r}}\) is the number of reflex vertices of the result.