Computational GeometryComputational geometry is a branch of computer science devoted to the study of algorithms whichcan be stated in terms of geometry. Some purely geometrical problems arise out of the study ofcomputational geometric algorithms, and such problems are also considered to be part ofcomputational geometry.Application of computational Geometry are : Robotics Geographic Information System(GIS) Integrated Circuit Design Computer Aided engineeringThe main branches of computational geometry are: Combinatorial computational geometry, also called algorithmic geometry, which deals with geometric objects as discrete entities. Numerical computational geometry, also called machine geometry, computer-aided geometric design (CAGD), or geometric modeling, which deals primarily with representing real-world objects in forms suitable for computer computations in CAD/CAM systems. This branch may be seen as a further development of descriptive geometry and is often considered a branch of computer graphics or CAD.Combinatorial Computational GeometryThe primary goal of research in combinatorial computational geometry is to develop efficientalgorithms and data structures for solving problems stated in terms of basic geometricalobjects: points, line segments, polygons, polyhedra, etc.Some of these problems seem so simple that they were not regarded as problems at all untilthe advent of computers. Consider, for example, the Closest pair problem: Given n points in the plane, find the two with the smallest distance from each other.One could compute the distances between all the pairs of points, of which there are n(n-1)/2,then pick the pair with the smallest distance. This brute-force algorithm takes O(n2) time; i.e.its execution time is proportional to the square of the number of points. A classic result incomputational geometry was the formulation of an algorithm that takes O(n log n).Randomized algorithms that take O(n) expected time, as well as a deterministic algorithmthat takes O(n log log n) time, have also been discovered. Computational geometry focuses heavily on computational complexity since the algorithmsare meant to be used on very large datasets containing tens or hundreds of millions of points.For large data sets, the difference between O(n2) and O(n log n) can be the differencebetween days and seconds of computation.
TesselationsTesselation is a tiling technique (that goes on forever) with shapes so that there is no overlappingand no gaps.Rules of Tesselation: The tessellation must tile a floor (that goes on forever) with no overlapping or gaps. Each vertex must look the same.Examples :
Each Vertex must count to 360 degrees also. 3,3,3,4,4These are not tessellations.
Because they are violating the overlapping rule or gaps are left in between the tiles.2. Practical life examples of tesselation Pavement Tiling Honey Comb Tessellated pavement Gaint Causeway and CauseWay coastTessellated pavement – It is a rare erosional feature formed in flat sedimentary rockformations lying on some ocean shores. The pavement bears this name because the rockhas fractured into polygonal blocks that resemble tiles, or tessellations.Gaint Causeway and CauseWay coast – It is an area of about 40,000 interlocking basaltcolumns, the result of an ancient volcanic eruption2. Tesselation as in Computer GraphicsIn the subject of computer graphics, tessellation techniques are often used to managedatasets of polygons and divide them into suitable structures for rendering. Normally, atleast for real-time rendering, the data is tessellated into triangles, which is sometimesreferred to as triangulation. Tessellation is a staple feature of DirectX 11 and OpenGLBut it doesn’t matter if you are just dividing the geometry into finer parts instead whatmatters is that if you are able to produce new details out of those vertices.
complexity depending on the target platform.The problem with this approach is that thefinal output is not consistent with the vision of the artist.The problem with denser and hence smoother meshes and models is the amount of storageand memory requirements. More detailed characters result in increase in load time andmemory demand of graphics card also increases.How tessellation is implemented:The basic unit for tessellation are patches (not triangles !!) which can be of any shape andcurve. Hull shader takes the control points for a patch as input and determines certainparameters of the Tesselator, such as, for example, TessFactor, which indicates the degreeof fineness of the tessellation. Tesselator is a fixed-function unit, so the programmer doesnot control how tessellation is calculated. The unit sends the points generated to the
Domain Shader, which can apply operations to them. A scenario :The major benefits derived from tessellations is the use of level of detail directly on the GPUand avoid using normal mapping. Now millions of polygons can be used for the polygoninstead of the normally thousands used these days.4. Tesselation as applied in OpenGLConvex Polygons : A polygon which follows these properties : Every internal angle is less than 180 degrees. Every line segment between two vertices remain inside or on the boundary of the polygon.Concave Polygons : A concave polygon will always have an interior angle with a measure that isgreater than 180 degrees.It is possible to cut a concave polygon into a set of convex polygonsOpenGL accepts only convex polygons for rendering, those non-convex polygons must betessellated before rendering and then the tessellator calls actual OpenGL commands torender the tessellated polygon through the user-defined callback routines.
Vertex coordinates (non – convex polygons) Tessellator Render the tessellated polygon through the user defined callback routines. The Tessellation PipelineNecessary Routines for implementing Tessellation in OpenGL GLUTessellator* gluNewTess() – creates a tessellation object. void gluDeleteTess(gluTessellator* tess) – deletes the tessellation object. void gluTessBeginPolygon(GLUtessellator *tess, void *userData) – begin declaring the concave vertex polygon data. void gluTessEndPolygon(GLUtessellator *tess) - finish declaring the concave vertex polygon data. Each concave polygon contains more than one closed contour. Each such contour must be declared within these function calls. void gluTessBeginContour(GLUtessellator *tess) void gluTessEndContour(GLUtessellator *tess) void gluTessVertex(GLUtessellator *tess, GLdouble cords, void *vertexData) - It specifies a vertex of a contour. - Tessellator uses these vertex coordinates to perform tessellation. - All the vertices should approximately lie on the same plane. - The second parameter is the vertex coordinates required for tessellation, and the third parameter is the data used for actual rendering. - It may be not only vertex coordinates but also color, normal and texture coordinates. void gluTessCallback(GLUtessellator *tess, GLUenum type, void (*fn)()) - During tessellation process, tessellator will call a series of callback routines when it is ready to render the tessellated polygon. You must provide appropriate callback functions, which contain actual OpenGL commands to render the polygon, such as glBegin(), glEnd(), glVertex*() etc. Void Tessnormal(GLUtessellator *tess , GLdouble x , GLdouble y , GLdouble z) - The surface normal of the polygon depends on the winding of the polygon. If the winding is counter clockwise,the normal vector of the polygon is coming out of the plane and if clockwise then into the plane. However we can specify the normal irrespective of the Default value is (0,0,0) which means the normal would be calculated based on windings.
Example of a tessellation A simple concave polygon – Tessellator deciedes by itself the most effective primitive type to draw the polygon. Here it deceides GL_TRIANGLE_FAN. The series of OpenGL calls are : glBegin(GL_TRIANGLE_FAN); glVertex3dv(v3); glVertex3dv(v0); glVertex3dv(v1); glVertex3dv(v2); glEnd(); A polygon with hole – The automatic OpenGL calls generated are : glBegin(GL_TRIANGLE_STRIP); glVertex3dv(v1); glVertex3dv(v5); glVertex3dv(v0); glVertex3dv(v4);glVertex3dv(v3);glVertex3dv(v7); glVertex3dv(v2);glVertex3dv(v6);glVertex3dv(v5); glEnd(); glBegin(GL_TRIANGLES); glVertex3dv(v5);glVertex3dv(v1);glVertex3dv(v2); glEnd();OpenGL determines the middle area is a hole by using winding numbers.Winding Rules and Winding Numbers : The winding rule determines which of the regions are inside or outside. So, the interior isfilled and the exterior is not filled.The winding number of a closed curve in the plane around a given point is an integer representing the total number of times that curve travelscounterclockwise around the point. The winding number depends on the orientation of the curve, and is negative if the curve travels around the point clockwise.
-2 -1 0 1 2 3Mathematical Definition of Winding numbers:The parametric equations of a xy plane is :If we think of the parameter t as time, then these equations specify the motion of an objectin the plane between t = 0 and t = 1. The path of this motion is a curve as long as thefunctions x(t) and y(t) are continuous. This curve is closed as long as the position of theobject is the same at t = 0 and t = 1.We can define the winding number of such a curve using the polar coordinate system.Assuming the curve does not pass through the origin, we can rewrite the parametricequations in polar form:The functions r(t) and θ(t) are required to be continuous, with r > 0. Because the initial andfinal positions are the same, θ(0) and θ(1) must differ by an integer multiple of 2π. Thisinteger is the winding number:This defines the winding number of a curve around the origin in the xy plane. By translatingthe coordinate system, we can extend this definition to include winding numbers aroundany point p.
The possible winding rules in openGL are : GLU_TESS_WINDING_ODD: Fill odd numbers, default setting GLU_TESS_WINDING_NONZERO: Fill non-zero numbers GLU_TESS_WINDING_POSITIVE: Fill positive numbers GLU_TESS_WINDING_NEGATIVE: Fill negative numbers GLU_TESS_WINDING_ABS_GEQ_TWO: Fill ABSolute values Greater than EQual to TWO If the basic figure is given below then the result of various interior regions shaded depending on the winding rules would be:
A self intersecting polygon -When the tessellation algorithm detects an intersection, then GLU_TESS_COMBINE callbackfunction must be provided in order to create the new vertex data, so we can draw it later.
Void combineCB(GLdouble newVert, GLdouble *neighbourVert,GLfloat neighborWeight, void **outData);The combine callback function is used to create a new vertex data when 2 edge linesintersect. It takes four arguments: newVert is an array of x, y, z coordinates as GLdouble.It is the position of the new intersected vertex which is found by tessellator. The secondargument is an array of pointers of four existing neighbor vertices, which make theintersection of 2 edges. The third is an array of four weight factors of four existing neighborvertices. The weights are used to compute interpolation values of color, normal, or texturecoordinates at the intersecting point. The last argument is the pointer to the output vertexdata. The output data may contain not only vertex coordinates but also color, normal andtexture coordinates. Tessellator will pass the output data into your GLU_TESS_VERTEXcallback routine in order to draw the intersecting vertex.The following OpenGL commands are generated by tessellator:glBegin(GL_TRIANGLE_FAN); glVertex3dv(v9); glVertex3dv(v0); glVertex3dv(v5); glVertex3dv(v7); glVertex3dv(v8); glVertex3dv(v2);glEnd();glBegin(GL_TRIANGLE_FAN); glVertex3dv(v6); glVertex3dv(v1); glVertex3dv(v7); glVertex3dv(v5); glVertex3dv(v3);glEnd();glBegin(GL_TRIANGLES); glVertex3dv(v4); glVertex3dv(v8); glVertex3dv(v7);glEnd(); ************