Hidden algorithm Two

Source: Internet
Author: User

abstract modeling is the basis of computer three-dimensional graphics processing, and blanking is the key to three-dimensional modeling. In this paper, the main 8 object space blanking algorithms and 4 image space blanking algorithms in CAD three-dimensional graphics processing are analyzed. ----keywords modeling, blanking, object space method, image space method----Classification Number----Modelling (modeling) is the basis of computer three-dimensional graphics processing, and the elimination of hidden surface (hidden surface, short-blanking) is the key to three-dimensional modeling. The so-called blanking is not to draw out that is hidden from the current observation point invisible three-dimensional model surface. The core of the blanking algorithm is to judge whether the surface of the three-dimensional model is visible. ----abstract, a blanking algorithm can be regarded as a five-tuple, i.e. ha=(I, O, D, P, S)----among them, I is a set of three-dimensional objects to be hidden processing;----O is a collection of two-dimensional objects that have been hidden from processing;----D The data structure used for blanking processing;----P is a set of basic operational procedures required for blanking processing, including classification and sequencing three-dimensional coordinate transformation perspective projection transformation the intersection between the basic graphical elements of the two regions overlapping judgment points and Orientation test of the area containing the test surface----S is a blanking strategy, that is, the order in which the basic operating procedures in P are applied. ----Therefore, we should consider the above five elements and their interrelation when designing the blanking algorithm. ----In computer graphics, in order to simplify the algorithm, the multi-faceted body is used to approximate the surface body, so the blanking algorithm is the basis of the surface body. In this paper, the blanking algorithm is mainly based on the problem of multi-faceted body, multi-faceted approximation of the surface body, the use of the multi-faceted blanking algorithm for each polygon can realize the curvature The blanking of the face body. ----based on B-the three-dimensional modeling blanking algorithm of the rep model (boundary representative model) and the CSG model (constructive Solid Geometry model) can be divided into two major categories, namely Object space method and image space method. Object Space method uses three-dimensional environmental information or three-dimensional view (mainly using three-dimensional observation coordinates, and sometimes using three-dimensional world coordinates) to eliminate the hidden surface, that is, according to the space of each object three Dimension model to determine which surfaces are visible and which surfaces are not visible. Image space method is based on two-dimensional display graph of object three-dimensional model (using two-dimensional display coordinates) to determine the near and far relationship between the object or the surface and the observation point, so as to determine which surface occlusion The other surfaces. ----This article will analyze the current three-dimensional graphics processing in the main 12 of the hidden algorithm, of which 8 belong to the object space method, 4The species belongs to the image space method. In the actual processing, because of the complexity of the surface morphology and the efficiency of the blanking processing, it is often used to complete the blanking of objects with a variety of blanking algorithms. ----I. Object space law----object Space method in three-dimensional coordinate system, through the analysis of the geometric relations between the object model, such as the geometric position of the object, and the relative position of the observation point, etc., to make the hidden surface judgment of the elimination Implicit algorithms. The world coordinate system describes the object's original coordinate system, and the object's world coordinates describe the basic shape of the object. In order to better observe and describe an object, it is often necessary to translate and rotate its world coordinates, and to get the observation coordinates of the object. The object's observation coordinates can get a better view of the object, so the object space method is usually carried out in the observation coordinate system. Observing the origin of a coordinate system is generally the point of view. ----Object Space method blanking consists of two basic steps, namely three-dimensional coordinate transformation and selection of the appropriate hidden surface judgment algorithm. ----a) three-dimensional coordinate transformation----Selecting the proper coordinate system can not only describe the object better, but also greatly simplify and reduce the operation of the blanking algorithm. Therefore, the first step of blanking using object space method is to convert the coordinate system of the object into the appropriate observing coordinate system. This requires a three-dimensional rotation and translation of the object. ----The original coordinates of the object vertex (x, y, z), the observed coordinates of the change (x*, y*, z*), you----1. The three-dimensional rotation transformation formula for rotation of the rotating transformation object around the y-axis is [x* y * z* 1]= [x y z] [cosαsinα0 0-sinαcosα0 00 0 1 00 0 0 1] The three-dimensional rotation transformation formula for the angle β of the object's rotation around the z axis is [x* y * z* 1]= [x y z] [cosβ0-sinβ00 1 0 0sinβ0 cosβ00 0 0 1] The three-dimensional rotation transformation formula for the angle gamma of the object's rotation around the x-axis is [x* y * z* 1]= [x y z] [1 0 0 xx corγsinγ00-sinγcosγ00 0 0 1] expands the above expression to the following formula {x' =cosαxx-sinαxz;y ' =cosβxy-sinβxx '; z' =sinαxx+cosαxz;x*=cosβxx ' +sinβxy;y*=sinγxz ' +cosγxy '; z*=cosγxz '-sinγxy ';----where x ', y ', and Z ' are the intermediate variables of the operation. ----2. Panning Transformations----The three-dimensional translation transformation formula is as follows [x* y * z* 1]= [x y z 1] [1 0 0 00 1 0 00 0 1 0Δxδyδz1]----expanded to get [x*=x+Δxy*=y+Δy z*=z+Δz----the Δx, Δy, and δz respectively are the amount of objects along the X, Y, Z axes. ----II) blanking algorithm----the commonly used object space blanking algorithms include plane formula method, back elimination method, radial pre-ordering method, radial sorting method, isolation plane method, depth sequencing method, ray tracing method and decomposition method. The first four algorithms are most commonly used, the basis of which is the back-blanking principle. The so-called back-blanking principle, that is, relative to the point of view of the object facing the surface is not visible, should be hidden. ----1. Plane Formula method----according to the analytic Geometry principle, the standard plane equation can be used to determine whether the given point is on the front or back of the plane. The plane formula method uses this principle to determine which side of the object's surface The observer is located on the back side, and the surface is not visible and should be hidden, otherwise visible. ----for an object to be arbitrary surface, it can be divided into several planes, in accordance with the coordinates of any three points on the plane can be obtained its plane equation. Standard get plane equation for ax+by+cz+d = 0;----where A, B, C and D are the constants for determining the plane. if (x1, Y1, Z1), (x2, Y2, Z2), (X3, Y3, Z3) are known to have three-point coordinates on the plane, a, B, C, and D will be obtained as follows: {a=y1 (x2-x3) +y2 (Z3-Z1) +y3 (z1-z2); B=Z1 (x2-x3) +z2 (x3-x1) +z3 (x1-x2); C=x1 (y2-y3) +x2 (y3-y1) +x3 (y1-y2);D=-x1 (Y2Z3-Y3Z2)-x2 (y3z1-y1z3)-x3 (y1z2-y2z1);----set the observer coordinates to (x, Y, z) if Ax+by+cz+d = 0, the Observer point (x, Y, z) is on the plane; Ax+by+cz+d > 0, the Observer (x, Y, z) is on the back side of the plane, the plane is not visible and should be hidden; Ax+by+cz+d < 0, the Observer (x, Y, z) is on the front side of the plane, and the plane is to be seen and should be drawn. ----by the proper rotation and movement of the object, the object can be transformed into an observation coordinate system with the observation point as the origin, if the plane equation is obtained in the observation coordinate system ax+by+cz+d = 0, the coordinate of the observer point (0,0,0), the following criteria can be derived as follows: D> 0, the plane is not visible and should be hidden; D< 0, then the plane is to be met and should be drawn out. ----The method of planar formula is simple, and it is the most frequent blanking algorithm in practice. But it can only be used for convex body blanking, but not for concave body blanking. ----2. Back elimination method----the back elimination method is a hidden algorithm that directly uses the back-blanking principle. In mathematics, the normal vector of an object's surface is the orientation of the surface, so the surface of the object from the normal vector to the point of view should be hidden. ----the normal vector of the surface can be determined by the dot product of the surface normal vector and the visual vector. As shown in Figure 1, after the coordinate transformation, the coordinate system of the Origin O is the observer point, the space of any plane abc normal vector is, the normal vector is the intersection of the plane with the p, then the vector op is the plane ABC The visual vector. ----If > 0, the surface of the object is visible towards the point of view, and if the surface of the object is invisible to the face of the observation point, it should be hidden. ----the angle between θ and vector and the length of the view vector is the length of the segment op | Op|, the =| is based on the definition of the vector dot product. op| | | cosθ. If > 0, then cosθ> 0 (i.e. >θ> 0); Conversely, if, then cosθ0(i.e. θ). ----Therefore, the criterion of the back elimination method is simplified as follows: cosθ0, the surface of the object is not visible and should be hidden; cosθ> 0, the surface of the object is visible and should be drawn. ----according to the definition of plane normal vector, we can select P1 (x1, y1, Z1) , P2 (x2, Y2, Z2), P3 (X3, Y3, Z3) in the plane by counterclockwise direction, then three points----(formula slightly)----among them:----(formula slightly)----after the projection changes, the view vector is parallel to the z axis, so the angle θ between the vector and the vector is the angle between the z axis and the vectors, so----Due to | | >0, so the positive and negative of the cosθ depends on C, so the criterion of the back elimination method is transformed into:----(formula slightly) C0, the surface of the object is not visible and should be hidden; C> 0, the surface of the object is visible and should be drawn. ----3. Radial pre-sequencing method----The radial pre-sequencing method determines which objects block other objects based on the angular position of the object in the XY plane of the three-dimensional coordinate system, and which surfaces of the object block other surfaces. For objects or surfaces with the same angular position, closer to the observation point will block the farther. As shown in Figure 2. Figure 2 Example of a radial pre-ordering method----The key point of blanking by the radial pre-sorting method is that the surface of the object and the object are sorted by far and near, and the object or surface with the same angular position is first drawn farther , the latter draws nearer, so that if the nearer object or surface blocks the farther object or surface, the obscured part is covered and the blanking is realized. However, for objects or surfaces with different angular positions, the first one to be drawn can be determined as needed. If there is the blanking of concave objects, it is generally necessary to draw the center part of the object first and then draw the sides of the object to correctly represent the overlapping concave model. ----The radial pre-ordering method can be used to eliminate the object of any shape. However, you need to know the angle of view beforehand and sort the drawing order of the object according to the corner position. Moreover, the coding of the constructed model is limited by this sort, and the model cannot be rotated. ----4. Radial sorting Method----The radial ordering method is an improved algorithm for the radial pre-ordering method, which makes the coding of the structural model automatically adjusts the near and far order of the object or surface according to the angle of observation. order to achieve a rotational transformation of the model so that the object can be viewed from different angles. The algorithm needs to detect the angle of rotation transformation and adjust the near and far order of the object or surface with the change of angle. ----5. Isolation Plane Method----The isolation plane method is mainly used for blanking between multiple objects, which is based on the plane formula method. The basic principle is to establish a virtual plane between two objects that need to be hidden, and to determine which of the two objects are located in the plane according to the plane formula method. Side, and which side of the plane is facing the observer, it can be inferred that the object located on the side of the plane toward the observer is closer to the observation point, and the occlusion is located in the planar back observation point Side of the object. The object that is located on the side of the plane back to the observation point should be drawn first and should be hidden. ----6. Depth Sorting Method----Depth ranking method is also used to analyze the existence of surface occlusion between multiple objects. The principle is to compare the z-coordinate of the representation of different objects or surfaces, in the observation coordinate system of the observer point in the origin, |z| The greater the value of an object or surface, the farther away from the observation point, the greater the likelihood of being hidden, which should be drawn first; |z|the smaller the value of the object or surface closer to the observation point, it will probably obscure the farther object or surface, should be drawn after. ----Depth sorting requires depth information and drawing order, which is commonly used in model data for object modeling that contains depth information and drawing order. ----7. Ray Tracing Method----the basic principle of ray tracing is that a person can see an object because it reflects light, so it tracks the light emitted from the light source, and the light is projected onto the object. , and then from the object to the point of view, the surface of the object closest to the observation point in the ray trajectory will obscure the surface of other objects. ----Ray-tracing method needs to analyze the light reflection state of every point of the object surface, so the memory space is large and the operation speed is slow. But this method can produce the light model of the object at the same time, and the hidden effect and realism are very good. ----8. Decomposition Method----decomposition method is a kind of blanking algorithm for CSG model, first, the complex object is decomposed into a series of cubes, and the cube near the observation point will obscure the far cube. , thereby achieving the elimination of the hidden. Decomposition algorithm complex, the need for large memory space, speed is full, nearly only for some special occasions. ----second, image space method----The image space method is based on the two-dimensional display graph of the three-dimensional model of the object to determine the proximity of each point on the object or surface to the point of view, thus determining which surface masks the other Surface In order to obtain the two-dimensional display graphics of three-dimensional objects, the object is subject to a perspective projection transformation after the change of rotating and moving objects. Figure 3 Perspective projection transformation schematic----as shown in Figure 3, the midpoint p (x, Y, z) of the three-dimensional space is transformed from perspective point e along the z-axis perspective projection to point p* in the Xoy two-dimensional plane (x*, y*, z*). Set e point distance from the Origin O is R, then the perspective projection Transformation Formula is:----(x*, y*, z*, 1) = (x, y, Z, 1) Mpempr----The MPE and MPr are the perspective transformation matrices and the projection transformation matrices, respectively, and their expressions are as follows:----(formula slightly)----When you expand the Perspective projection Transformation formula, you get:----(formula slightly)----1. Z-Buffer Method----The z-buffer method first establishes a large buffer, which is used to store all the pixel values of the two-dimensional graph obtained by the three-dimensional object along the z-axis perspective, and is therefore called the Z-buffer. The number of cells in the Z-buffer is the same as the number of pixel points on the screen, and the number of units in the frame buffer is the same, and they are one by one corresponding. The size of each cell in the z-buffer depends on the range of changes in the z-direction of the graph in the viewing coordinate system. The value of each cell in the z-buffer is the z-coordinate value of the object's surface point corresponding to the pixel point. ----The process of blanking and modeling using Z-buffer method is to judge each point in the screen and assign the corresponding unit in the frame buffer and z-buffer. The algorithm is described in formal language as follows: Z-buffer blanking algorithm {1) Set the value of the frame buffer unit to the background color value;2) Set the value of each cell in the z-buffer to the maximum possible value for z-coordinates;3loop: For each object {loop: A Perspective projection transformation (x, Y, z) for each point (x, Y, z) of each facet of an object, resulting in the transformed X and y coordinates (x*, y*); ii) if the z-buffer (x*, y*the value of the corresponding cell is less than Z, then {a) the z buffer (x*, y*the value of the corresponding cell is set to Z;b) in the frame buffer (x*, y*the value of the corresponding cell is set to the attribute value of the point (x, Y, z) (usually the index value of the luminance, color value, or color lookup table);} III) If the z-buffer (x*, y*the value of the corresponding cell is greater than Z, {a) indicates the current frame buffer (x*, y*The point on the object represented by the corresponding cell (x, y, z) is closer to the point of view, i.e. the point (x, Y, z) should be hidden; b) the z buffer and the frame buffer (x*, y*the value of the corresponding cell remains the same; }}}4) Cycle: To every point on the screen (x*, y*) According to the frame buffer (x*, y*the value of the corresponding cell draws the pixel point. }----the Z-buffer blanking algorithm is simple and reliable, and the blanking and performance is very good. However, the required memory capacity is large, the operation is complex and time consuming. ----2. Scanning Line Method----The scanning line method is a kind of blanking algorithm which is derived from the improvement of Z-buffer method. In order to overcome the disadvantage that the Z-buffer method needs to allocate huge memory with the same number of pixel points on the screen, the entire screen can be divided into several regions , a zone is processed so that the number of cells in the z-buffer can be reduced to the number of pixel points on the screen in one area. The line of the screen as such area, you get the scanning line method, also known as the scan line Z buffer method, Z buffer cell number is only the number of pixels on the screen line. ----the formal language of the scanning line method is described as follows: Scan line blanking algorithm {1loop: From top to bottom, each scan line in the screen {i) set the value of each cell in the frame buffer corresponding to the background color value; ii) set the value of each cell in the z buffer to the maximum possible value of the z-coordinate; iii) loop: For each object {loop: Each surface of the object { If the current scan line intersects the current object's surface, {loop: The scan line is paired with the intersection of the current object's surface, and each point (x, Y, z) {A) between each pair of intersections is given a perspective projection transform (x, Y, z) to get the transformed x and y coordinates (x*, y*); B) if the z-buffer (x*, y*the value of the corresponding cell is less than Z, then {a) the z buffer (x*, y*the value of the corresponding cell is set to Z;b) in the frame buffer (x*, y*the value of the corresponding cell is set to the attribute value of the point (x, Y, z) (usually the index value of the luminance, color value, or color lookup table);} C) If the z-buffer (x*, y*the value of the corresponding cell is greater than Z, {a) indicates the current frame buffer (x*, y*The point on the object represented by the corresponding cell (x, y, z) is closer to the point of view, i.e. the point (x, Y, z) should be hidden; b) the z buffer and the frame buffer (x*, y*the value of the corresponding cell remains the same;}}}} IV) Cycle: to each point on the screen (x*, y*) According to the frame buffer (x*, y*the value of the corresponding cell draws the pixel point. }}----3. Line of sight projection method----the basic principle of line-of-sight projection is to view the object's two-dimensional display image as a projection of the object's visible point onto the display from the eye to the object's sight. The formal language of the algorithm is described as follows: line of sight projection blanking algorithm {1) Cycle: to each pixel on the screen (x*, y*{determined by the viewpoint and pixel (x*, y*Line Ray ; Determines whether the line ray (x, Y) intersects the object, and if there is an intersection, {a) the first intersection of the line ray with the object (x, y, z); b) the intersection (x, y, z) is the visible point, and the rest of the intersections should be hidden; c) point (x, Y, Z) is assigned to the pixel (usually the index value of the luminance, color value, or color lookup table) (x*, y*);}}2) Cycle: To every point on the screen (x*, y*) to draw a pixel (x*, y*) corresponds to the property value. }----4. Extremum Detection Method----The extremum detection method, which is used in conjunction with other blanking algorithms, is mainly applied to increase the blanking speed. The Extremum detection method determines whether there is overlap between the two surfaces by calculating the maximal and minimum values of the display coordinates of the object surface. If the x display coordinates of a surface have a maximum value less than the x display coordinates of the other surface, the two surfaces do not overlap and can be drawn directly in any order. Otherwise, the two surfaces overlap, and other blanking algorithms need to be used to eliminate the hidden processing. ----usually first use the Extremum detection method to draw a surface that does not overlap, and then use other algorithms to process overlapping surfaces.

Hidden algorithm Two

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.