Sprinklers Layout Design – Computer Graphics Project 2004/2005

















1.     Abstract

Sprinklers Layout Design is a Win32 program that manages showing, inserting, deleting, moving, grouping and arranging water sprinklers (in fact, their approximate prototypes) on a polygon representing user’s garden or grass lawn. The water “covering the garden” is shown according to precipitation level at each point (pixel on raster screen). The color scheme used is water-imitative – from very light cyan to deep blue, according to the precipitation level.

Return to the top


2.     Downloading, compiling, launching and using the program

Files available for download:

Compiled program executable and database (ZIPPED)

Full Microsoft Visual Studio .NET 2003 solution (ZIPPED)

This entire site (ZIPPED)

·        If you want just to run the already-compiled program executable, take the first file in the list above. Using the program is very simple – as any MFC MDI program. You can open garden files that must have the SGA extension (see docs below) and edit their sprinkler configurations (detailed description in the Program Features section), and save or discard your changes to the gardens.

·        If you want to compile the program yourself, take the Visual Studio solution. It comes without temporary object files and executables because otherwise the page would overflow the disk quota on this server. Open the solution (of course, you must have the software mentioned above to run it). Choose the configuration you want (debug or release) and launch the compiling (note: because the program is dealing with two-dimensional array computations, the release configuration is pretty much faster than the debug one). When the program is launched, a sprinkler series database file called Sprinkler Series Database.MDB must be present, inside a directory called Database that is to be placed in the same path as the program executable file (therefore, if you compile the program yourself, do not run the executable directly from Debug of Release directories, but from the Visual Studio solution desktop; or just copy the executable one level up to the root folder of the solution where the database is initially located, or copy the Database directory to each one of the Debug and Release folders). From this point, you can now edit and debug the code as you wish or just test how the program runs.

Return to the top


3.     Model and assumptions

·        The gardens are simple, not necessarily convex polygons that can be approximations for more advanced forms like circles or ellipses if they have enough vertices.

·        The sprinklers in the program are irrigation facility objects that are modeled to be close enough to real life sprinklers. Every sprinkler has its own position. Every sprinkler belongs to some sprinkler series whose features are reflected in the program database. Each series can be rotary (sprinklers that apply thin rotating water jet) or spray (reduced-radius sprinklers that spray water to all the directions simultaneously). Each series has a finite set of nozzles that accept different range of water pressures, and apply different irrigation radii range and flow range to the garden area. The three parameters are dependent when the pressure is the main one. If you increase the pressure from its minimum (predefined in the database) to the maximum, the radius and flow grow by the same factor, from their minima towards their maxima. For example:

























Flow (m3/hour)




The sprinklers in the program are assumed to operate in circular pattern, though in real life, wind and slope conditions can dramatically affect this ideal assumption. Also, some companies recently have started to produce special rectangular-patterned sprinklers that are not covered here since they are not common.

·        The water in the program is represented by coloring “irrigated” pixels with different variations of cyan and blue colors that are traditionally associated with it. Each point (in fact, its pixel approximation) of the garden is subsequently colored according to the quantity of water falling onto it, in other words, according to is precipitation level. Precipitation is measured in millimeters per hour and stands for the height of “water pillar” accumulated at an infinitesimally small point on the garden during one hour of irrigation. If we have some area, , and some flow,  (measured in cubic meters per hour, i.e. it is the hourly applied water volume), and assume that the flow distribution is uniform, the precipitation at each point of  equals to . Of course, the assumption of uniformity is not real for a single-standing sprinkler. The flow it produces is distributed non-uniformly. In fact, the program’s assumption is that the water precipitation level is maximal at the sprinkler’s head, and falls linearly to 0 mm/h at radius distance:










This assumption is a clear simplification of real-life water distribution function that is difficult to express in functional form. In fact, it might be something like this:










Given flow and radius parameters (for current pressure level), we can calculate what is the maximal precipitation, i.e., the one at the center of the sprinkler’s circular irrigation pattern. Because the precipitation is a value applied to an infinitesimal point, and it decreases constantly as the radius increases, the overall flow formula is:

Hence, the precipitation at the circle center that is the maximal for given sprinkler, can be derived from this formula:

From here we can derive another useful fact: since the maximal (center) precipitation depends on , for given  and  (that depend both on pressure), the center precipitation does not depend linearly on pressure. I.e., we might increase the pressure to some level (between given minimum and maximum), and flow and radius will increase too (by the same percentage), - but the center precipitation might increase as well as decrease. To illustrate this, let’s express this in a mathematical way. According to international standards and our database model (see below), we must be given the minima and the maxima of the three dependent parameters, – pressure, irrigation radius and flow. Let’s denote them as , , , ,  and . If we have increased the pressure by percentage  (), the current parameter values are  for pressure, and, because the three parameters are dependent,  for radius and  for flow. And these are actually the formulae for the three principal parameters’ growth. So the center precipitation at percentage  of pressure range is:

Here the constants are denoted by ,  etc., for easier calculations. Clearly, the above function is not linear, therefore let’s take the first derivative and determine how the function behaves:

Let’s solve the equation for maxima and minima:

I.e., the function has single extremum point. Let’s check whether it’s maximum or minimum:

I.e., it is a maximum.

So, we might increase pressure (and subsequently radius and flow), but the maximal (center) precipitation behaviour is not linear, so in the given radius-flow range it might increase constantly (if its maximum is beyond ), decrease constantly (if it is beyond ), or pass through the maximum, while at the endpoints of the range it may be equal at  and , larger at  than at  (in the Sprinklers Layout Design program it is called “increases in general, passing through the maximum”), or less at  than at  (“decreases in general, passing through the maximum”). The information about all this, as well as about the pressure corresponding to maximal center precipitation (if it lays in the given pressure range), appears on the nozzle options dialog (see below). IMPORTANT NOTE: if we take some pressure-radius-flow configuration, there is a unique maximal precipitation (at the center of the sprinkler’s circle) that corresponds to it. And the precipitation inside the circle decreases linearly, from maximum to 0, as radius increases. This is our assumption about precipitation behaviour from above, depending on radius and when given constant pressure-radius-flow configuration. I.e., if you have a sprinkler and have set up some pressure for it, the inner part of your irrigation circle is linearly wetter than its margins. This function must not be confused with the calculations we made about maximal precipitation level only, and about how it depends on changing pressure-radius-flow. This information is important for sprinkler system superintendents that want to adjust their sprinklers to optimal levels of maximal precipitation near the sprinkler head. The info about how the maximal precipitation changes depending on pressure is displayed for every nozzle in nozzle options dialog (go to menu  sprinklers  browse the current database and see inside the sprinkler series listed). For example, here is a dialog for a nozzle whose central precipitation reaches its maximum inside the given pressures range.

Return to the top


4.     Program Features


4.1        General Features

The program was written in C++ language, using Microsoft Visual Studio .NET 2003 IDE and MFC. It uses Multiple Document Interface (MDI) template, so several gardens (garden files) can be edited in a single session. A standard MFC mechanism has been chosen, i.e., a main frame window, menu, toolbars and child windows.

Return to the top


4.2        Parsing Files and Displaying Gardens

The files representing the gardens have the extension SGA (stands for sprinkler garden). These are simple text files of the following structure:


GARDEN <garden name>

MINIMALPRECIPITATION <minimal acceptable precipitation for this garden>

MAXIMALPRECIPITATION <maximal acceptable precipitation for this garden>












Such a file contains a garden represented by a set of vertices (i.e., it is polygonal, though non-polygonal gardens could be represented by a larger set of vertices that approximates their shape. Here is a round garden, for instance. The list of vertices is enclosed between the “keywords” VERTICES and ENDVERTICES in the file. The garden file must contain also the keyword GARDEN with garden’s name after it (first row), the keyword MINIMALPRECIPITATION with a floating-point value of minimal acceptable water precipitation (in mm/h) for the garden (second row), and corresponding maximal precipitation (same manner, third row). These values may vary because the accepted international standard characteristic for irrigation is mm per day and not per hour. For example, if your garden wants between 25 and 100 mm of water per day, and you intend to irrigate it, say, 5 hours a day, then acceptable precipitations for your garden file must be 5 and 20, respectively. But if you intend to irrigate it only 2 hours a day, everything must change accordingly.

Then, the garden must contain some sprinklers (every sprinkler’s description must be written in one row, all the descriptions are enclosed between SPRINKLERS and ENDSPRINKLERS keywords; if currently there are no sprinklers, the keywords must appear anyway). The sprinkler’s description consists of 7 values: sprinkler series number in the database, current nozzle number (integers beginning from 1), sprinkler’s x and y coordinates (floating-point values referring to the same coordinates origin as do the garden’s coordinates above), percentage of pressure applied to the sprinkler (floating-point value, 0 or 0% corresponds to the minimal pressure available, 1.0 or 100% corresponds to the maximal pressure available), sprinkler’s 2D orientation (floating-point value up to 359.0, in degrees), and sprinkler’s irrigation pie sector (floating-point value up to 360.0, in degrees).

The garden is parsed according to such a structure of an SGA file. The vertices are stored in the order they are written in, and in this way the polygon is formed. Also, a sprinklers database file (an MDB i.e. Microsoft Access file) is loaded on program start. Sprinklers given in the file are parsed according to this database. If parsing encounters an error (a format error, i.e. if the file format does not match the format template above; a vertices error, i.e. if the vertices number is less that 3; a sprinkler error, i.e. if there is a nonexistent sprinkler in a file etc. etc.), the garden document is not created and an error message is displayed. If the parsing succeeds, the polygonal garden is displayed onto the screen using OpenGL polygon primitive with golf lawn texture, and so are its sprinklers. By default, the water distribution is shown but user can hide it while displaying only the sprinklers themselves (using a small bitmap designating a sprinkler in each sprinkler location).

Return to the top


4.3        The Sprinklers Database and Database Operations

The sprinklers database is an MDB (Microsoft Access database) file named “Sprinkler Series Database”. It consists of two tables (sprinkler series and their corresponding nozzles). A record in the sprinkler series table represents a reality-approximated sprinkler type (since the irrigation gear producers produce “series”, i.e., basic sprinkler types that can be used with a set of several nozzles). The fields in the record are: the series code (an integer starting from 1), the series name, the name of its producer, and a Boolean field that indicates whether the series is of rotary sprinklers or of spray sprinklers. This is important for the user since the rotary sprinkler’s flow increases as its working sector decreases, while in spray sprinklers it decreases whilst the sector is decreased. This difference is not shown in water distribution schemes, so the user must always remember that if he has a set of rotary sprinklers when some of them have their working sectors reduced by factor  (for instance, when a sprinklers grid forms a rectangle), he must reduce their operation time by the same factor  (relatively to the full circle sprinklers). The nozzles table contains the nozzle sets corresponding to the sprinkler series. Each nozzle record contains: the integer code (the same one that the corresponding sprinkler series has); the nozzle name (string); the operating trajectory (this parameter is informative-only, it’s not actually used by the program); the minimal and maximal operating pressure, minimal and maximal operating radius and minimal and maximal water flow (all the six are floating-point values, radius and flow change as the pressure changes, i.e. pressure, radius and flow are dependent whilst the pressure is the primary parameter); sector adjustment mode (it’s a Boolean value, it can be continuous, - let’s say, from 25° to 360°, or discrete, i.e. with limited number of available sectors, - let’s say, three sectors of 90°, 180° and 270°); minimal and maximal available sectors (floating-point values, not relevant for discrete adjustment mode); available discrete sector flags (Booleans, not relevant for continuous adjustment mode).

The sprinkler series database is loaded into the program on startup and can be viewed and modified using special dialogs. View sprinkler database dialog, sprinkler series dialog and nozzles dialog for example. The two latter dialogs also serve as insertion dialogs.

Return to the top


4.4        Navigation and Viewing-Related Features

The program offers several navigation modes and viewing options. The document view can be manipulated in various ways. It can be:

·        Scaled up and down (every time by factor 1.5). See scaling up and scaling down examples.

·        Viewed without any special navigation effects (mode 1, the button showing the regular arrow-shaped mouse), or it can be scrolled to any of four directions (mode 2, button showing a hand). This option has no effect when the view is not scaled enough to have scrollbars.

When the view is scaled up so the document can be only partially viewed (using scrollbars), and the user has been scrolling it back and forth, it can be reset back to the middle-viewing position by a special button “reset to middle”. This button is enabled only if the garden is scaled up.

·        The garden can be viewed with water distribution hidden or shown. If the water distribution is shown, the garden’s sprinklers can be viewed in three modes – popping up when the mouse pointer passes closely to them (i.e., one sprinkler at a time), be shown unconditionally over the water distribution, or hidden unconditionally.

·        When the water distribution is shown, it can be shown with two special options – under- and over-wetting markings. Under-wetting is shown in yellow, over-wetting – in deep red. These options imply marking the garden points that don’t receive enough or receive too much precipitation per hour. These options can be used interchangeably, used together, or not used at all. The areas marked as under- or over-wetted depend on the values of minimal and maximal precipitations for specific garden (see above).

·        The water can also be shown in two modes: global and local. The global mode implies that the precipitation values are assigned color values relatively to the maximal precipitation level of the entire program (it gets the deepest blue color). The local mode is more convenient to see how the irrigation levels change from point to point, because in this case the maximal precipitation value currently available on the opened garden is assigned the maximal color value (the deepest blue), and the coloring is more sharp. Also, in any color mode, if the user wants to see what regions of the garden get a specific range of precipitations, he can highlight these regions in purple color using a special dialog.

Return to the top


4.5        Changing Garden Parameters

In this program, the garden parameters are its minimal and maximal precipitation settings. These values can be changed using the corresponding dialog. It is launched from Operations – Garden Parameters menu.

Return to the top


4.6        Placing Sprinklers

Sprinkler objects can be placed onto the garden in several ways:

·        A single sprinkler can be placed onto the garden using the mouse pointer. When the program is in appropriate mode (placing single sprinkler mode), the mouse pointer is used to derive the placing coordinates. When the mouse button is pressed, a special sprinkler options dialog pops up so that the user could select the sprinkler type that fits his needs the most. All the parameters are shown and sprinkler preview is also available. The parameters slider adjusts the pressure from minimal to maximal, and together with it radius and flow are also changing. The two other sliders adjust sector and orientation. If sectoring is discrete, a list box of available sectors opens up instead of sector slider.

·        A group of sprinklers (actually, a sprinklers grid) can be placed using two different spacing options – quadratic (when the sprinklers are placed in rectangular pattern) or triangular (in triangular pattern). Numbers of rows and columns in each case can be modified using special dialog that pops up when this placing option is selected. Spacing mode and distance between sprinklers can also be handled from this tiny dialog that also shows a proportional preview of the grid’s “unit cell”. Appropriate sliders smoothly adjust horizontal and vertical distances. Two buttons are available for placing a sprinkler group onto the garden. The only difference is the spacing mode selected initially. When the mouse hovers over the garden, the future grid scheme moves together with it so the user could know exactly where to place the grid. As he clicks the mouse button the grid is placed. See quadratic and triangular placing examples.

Return to the top


4.7        Selecting and Manipulating Sprinklers

Sprinklers can also be selected. It can be done in two modes:

·        Select sprinklers one by one. The user must choose the appropriate selection mode and then he selects sprinklers one at a time by clicking them with the mouse. If the sprinkler is already selected and CTRL key is not pressed, the sprinkler is deselected.

·        Select a group of sprinklers. The user, after choosing the appropriate mode, selects a group of sprinklers by clicking the mouse and dragging a selection rectangle over the garden. The sprinklers that are inside the rectangle are selected and highlighted. Every new group selection deselects previously selected sprinklers.

All the sprinklers can also be selected by selecting the appropriate item in the operations menu or by using the standard CTRL+A key combination

Two operations can be done on selected sprinklers. They can be deleted (using a menu item or toolbar button) or moved within the view (by dragging them with the mouse to any point or by using arrow keys that drag them along horizontal and vertical lines).

When the user is not manipulating sprinklers in special modes (placing, deleting or moving), double-clicking them with the mouse will cause their properties dialog pop up (the same one used when placing sprinklers). Thus the sprinkler’s parameters can be modified.

Return to the top


4.8        Garden coefficients

The irrigated garden has its special coefficients that reflect water distribution uniformity, minimal scheduling, and precipitation area parameters, such as driest and wettest area “windows”. You can see these coefficients by pushing the coefficients button on the toolbar or selecting the appropriate item in the view menu.

The coefficients described:

·        The overall average precipitation (total average, or TA coefficient) is calculated by using the discrete precipitations array (that is used to draw the water distribution) in a trivial manner – summing and dividing by points number. Of course, the bigger the scale, the more exact this parameter is.

All the other coefficients are calculated using a rectangular “window” (5% of garden size in each axis) passing over the garden. It simulates the real-life coefficients calculation that uses placing catch cans on the garden and measuring the caught precipitation in different areas. For every such window, the average precipitation within it is calculated and stored. The standard uniformity coefficients information can be seen at the CIT (Center for Irrigation Technology) page, and their formulae are taken from there and related pages.

·        The driest area average (DA coefficient) is the smallest number of the above averages.

·        The wettest area average (WA coefficient) is the largest number of the above averages.

·        The coefficient of uniformity (CU) is calculated as , where  stands for total catching windows number,  is the th catching window precipitation average, and  is the total area average (see above). The closer this coefficient is to 1, the better the uniformity is.

·        The distribution uniformity (DU) coefficient is another, a bit more advanced coefficient to judge the precipitation uniformity level. It is calculated as , where all the notations are the same as above, except that now the catching windows averages are sorted in increasing order. I.e., we sum here the lowest 25 percent of the averages. The closer this coefficient is to 1, the better the uniformity is.

·        The scheduling coefficient (SC) is a coefficient that shows how much time the system must be operated (relatively to the original time plan) so that the originally driest areas would receive the precipitation quantity equal to the original total area average. Its formula is simple: . Of course, it is desirable that this coefficient would be as close to 1 as possible, too. Note that this coefficient shows how much time you should operate all your system relatively to the original plans in order to cause the driest areas get more water, and not how you should schedule your sprinklers one relatively to another (for example, as was said above, reducing the partial-circle rotor sprinklers operation time relatively to the full-circle ones).

Return to the top