======
Curves
======

Curves are a type of primitive geometry in |HPSNOW|. They include circles, circular arcs, ellipses, elliptical arcs, and NURBS curves. Circles, circular wedges, and ellipses are facetted objects whereas the others are not. This differentiation is important because facetted objects have *edges* while non-facetted objects are made of *lines*. This section does not cover NURBS - see :doc:`section 2.11 <0211_nurbs>` for that discussion.

The ``HPS::CurveAttributeControl`` is a segment-level control that groups attributes related to rendering curved lines and edges. Examples of attributes that can be controlled are tessellation, maximum angles between adjacent line segments, and whether the tessellation of curves will be view independent. See the reference manual page on this control for more information about these settings. Note that all of the example screenshots on this page are shown with face visibility turned off for clarity. If you would like to show geometry in this way, you should create the geometry in a segment that has disabled face visibility.


Circles
=======

A circle is a type of geometric primitive in |HPSNOW|. Note that although all curves, including circles, are 2D objects, all exist in 3D space. |HPSNOW| has no exclusive concept of 2D. To draw a circle, simple provide the center point, normal vector, and radius:

.. tabs::

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

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_curves.cs
		   :start-after: //! [020501_a]
		   :end-before: //! [020501_a]

The normal vector sets the circle's orientation in space. In order for it to appear circular, the normal must point directly at the camera.

.. image:: images/circle.png

*A simple circle*


.. _circular_arcs:

Circular Arcs
=============

Circular arcs are made using the circular curve over three distinct points along the circumference of a circle. If a circle cannot be formed using the three supplied points, the geometry is not inserted. As circular arcs are not facetted, its line attributes are controlled by the ``LineAttributeControl``.

.. tabs::

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

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_curves.cs
		   :start-after: //! [020502_a]
		   :end-before: //! [020502_a]
		   
.. image:: images/circular_arc.png

*A circular arc. The marker indicates the origin.*


.. _circular_wedges:

Circular Wedges
===============

Circular wedges are similar to circular arcs, except the endpoints are drawn to the center of the "circle". They are defined analogously as three points along a circumference. Like other facetted geometry, the circular wedge can be filled with a color.

.. tabs::

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

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_curves.cs
		   :start-after: //! [020503_a]
		   :end-before: //! [020503_a]
		   
.. image: images/circular_wedge.png

*A circular wedge*


Ellipses
========

In the real world, a circle is a type of ellipse, but in |HPSNOW| they are unrelated from a class inheritance perspective. To insert an ellipse, all that is needed is the center point, the major axis, and the minor axis. The ellipse is considered to be faceted geometry.

.. tabs::

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

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_curves.cs
		   :start-after: //! [020504_a]
		   :end-before: //! [020504_a]
		   
.. image:: images/ellipse.png

*An ellipse*


.. _elliptical_arcs:

Elliptical Arc
==============

An elliptical arc will make an arc out of a portion of an ellipse. The portion that is to be drawn is specified using start and end parameters. These parameters indicate the normalized parametric angle along the ellipse's perimeter, in the direction from the major to minor axis, where the arc begins and ends. For example, use the code below to create an arc out of about 75% of an ellipse:

.. tabs::

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

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_curves.cs
		   :start-after: //! [020505_a]
		   :end-before: //! [020505_a]
		   
The *start* of the ellipse is the point that locates the major axis, and the retained portion is swept over the ellipse in a counter-clockwise fashion.

.. image:: images/elliptical_arc.png

*An elliptical arc*
