=====
Grids
=====

|HPSNOW| supports the use of grids. Grids are often used as reference points, reference lines, or as guides for placing objects. Grids are planar, and cells can be square, rectangular, angled (parallelogram), or radial.

Grids are implemented as a collection of faces with edges and vertices. As such, the grid's edge attributes are controlled by the ``HPS::EdgeAttributeControl``, and the vertex attributes are controlled by the ``HPS::MarkerAttributeControl``. Attributes for a grid apply to the grid as a whole - you cannot set attributes on subparts.

One advantage of grids is that they can be infinite in extent. So, if you are using a grid as a background, you do not have to worry about how large to make the grid. |HPSNOW| computes which parts of the grid are visible, and draws only those parts.

.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../internals/tests/docs/source/cpp/00700_grids.cpp
		   :start-after: //! [grids_1]
		   :end-before: //! [grids_1]
		   
	.. group-tab:: C#

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_grids.cs
		   :start-after: //! [grids_1]
		   :end-before: //! [grids_1]
		   
.. image:: images/grids_1.png

*The grid produced by the above code*

The calls to ``SetFirstPoint`` and ``SetSecondPoint`` represent a vector from the origin to which the point is drawn for each axis of the grid. The point is then repeated at regular intervals. By specifying two vectors that are not perpendicular, you can create non-traditional shapes for grid cells.

If you specify zero for the grid counts, the grid will extend infinitely. When viewed in perspective, infinite grids are drawn to infinity, smoothly vanishing toward the horizon.

.. image:: images/grids_2.png

*A grid with zero for the grid counts extends to the horizon*


Radial Grids
------------

Radial grids follow the same rules as quadrilateral grids. The only difference is that you would specify the ``HPS::Grid::Type::Radial`` enum when setting up the grid.

.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../internals/tests/docs/source/cpp/00700_grids.cpp
		   :start-after: //! [grids_2]
		   :end-before: //! [grids_2]
		   
	.. group-tab:: C#

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_grids.cs
		   :start-after: //! [grids_2]
		   :end-before: //! [grids_2]
		   
.. image:: images/grids_3.png

*A radial grid*


Customizing the Appearance
--------------------------

The appearance of the grid lines can be customized to fit your needs. In this example, a :doc:`custom line pattern <0406_line_patterns>` and face color are applied to the grid. See :doc:`our section on portfolios <0401_portfolios_introduction>` for more details on applying materials to lines and faces.

.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../internals/tests/docs/source/cpp/00700_grids.cpp
		   :start-after: //! [grids_3]
		   :end-before: //! [grids_3]
		   
	.. group-tab:: C#

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_grids.cs
		   :start-after: //! [grids_3]
		   :end-before: //! [grids_3]
		   
.. image:: images/grids_4.png

*A grid configured with a line pattern and color*
