The Geometry concept is one of the core concepts of the sgCore library.


The objects the user models with the help of the library have two basic points - a mathematical description of the object and its polygonal (for 3D objects) or segment (for 2D objects) presentation. The mathematical description of the object is called geometry in the sgCore library.


Geometry is an independent concept. Geometry describes a mathematical object with high accuracy and there is one-to-one relationship between them.

The geometry accuracy is limited only by the accuracy of the number presentation in the processor.


Examples of geometries:


circle geometry. To describe a circle in the three-dimensional space you should set 7 numbers - a circle radius, three coordinates of the center and three coordinates of the normal vector. In fact, the SG_CIRCLE structure realizes this presentation.


sphere geometry. To describe a sphere in the three-dimensional space you should set 4 numbers - a sphere radius and three coordinates of the center. The position of any object in space can be unambiguously described by an affine transformations matrix. This way of setting the 3D objects position is used in sgCore library. That is why you only need to know the sphere radius to describe the sphere geometry. If you want to transform the mathematical "sphere" description into a polygonal model you shoud also know the number of meridians and parallels.

The SG_SPHERE structure realizes the sphere geometry described above.


Besides the fact that a geometry stores an accurate mathematical description of an object, it has one more advantage. It allows you to quickly draw a 2D object segment presentaion without creating the object itself. Thus, there is a Draw function for arcs and circles which draws this or that geometry segment by segment. The segment presentation of a spline is stored in the array of points and with its help you can draw a spline geometry.


See also