Nonzero-rule

Nonzero-rule
A curve (top) is filled according to two rules: the even-odd rule (left), and the non-zero winding rule (right). In each case an arrow shows a ray from a point P heading out of the curve. In the even-odd case, the ray is intersected by two lines, an even number; therefore P is concluded to be 'outside' the curve. By the non-zero winding rule, the ray is intersected in a clockwise direction twice, each contributing -1 to the winding score: because the total, -2, is not zero, P is concluded to be 'inside' the curve.

In two-dimensional computer graphics, the non-zero winding rule is a means of determining whether a given point falls within an enclosed curve. Unlike the similar even-odd rule, it relies on knowing the direction of stroke for each part of the curve.

For a given curve C and a given point P: construct a ray (a straight line) heading out from P in any direction towards infinity. Find all the intersections of C with this ray. Score up the winding number as follows: for every clockwise intersection (the curve passing through the ray from left to right, as viewed from P) subtract 1; for every counter-clockwise intersection (curve passing from right to left, as viewed from P) add 1. If the total winding number is zero, P is outside C; otherwise, it is inside.

The winding number is effectively a count of how many full counter-clockwise revolutions ('windings') the curve makes around P without doubling back on itself. (If P were a nail and C were a looped piece of string, try pulling some part of the string sideways away from the nail: it will either come free, or it will be found to be wound some number of times around the nail.) Some implementations instead score up the number of clockwise revolutions, so that clockwise crossings are awarded +1, counter-clockwise crossings -1. The result is the same.

One formal definition of the winding number of point P with respect to curve C (where P does not lie on the curve) is as follows:

Consider a point Q that travels once around C. The endpoint of a vector from P to Q, after normalization, travels along the unit circle centered at P. If we imagine the track of this endpoint as a rubber band, and let the band contract, it will end up wrapped about the circle some number of times. The winding number is the number of wraps (for clockwise wraps, the winding number is negative).[1]

References

  1. ^ James D. Foley, Andries Van Dam, Steven K. Feiner & John F. Hughes (1996) Computer Graphics: Principles and Practice p. 965. Addison-Wesley. ISBN-9780201848403

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Rule of inference — In logic, a rule of inference (also called a transformation rule) is a function from sets of formulae to formulae. The argument is called the premise set (or simply premises ) and the value the conclusion . They can also be viewed as relations… …   Wikipedia

  • Even-odd rule — The even odd rule is an algorithm implemented in vector based graphic software, like the PostScript language, which determines how a graphical shape with more than one closed outline will be filled. Opposite: nonzero rule.The SVG specification… …   Wikipedia

  • Cramer's rule — In linear algebra, Cramer s rule is a theorem, which gives an expression for the solution of a system of linear equations with as many equations as unknowns, valid in those cases where there is a unique solution. The solution is expressed in… …   Wikipedia

  • Descartes' rule of signs — In mathematics, Descartes rule of signs, first described by René Descartes in his work La Géométrie, is a technique for determining the number of positive or negative real roots of a polynomial. The rule gives us an upper bound number of positive …   Wikipedia

  • Triple product rule — The triple product rule, known variously as the cyclic chain rule, cyclic relation, cyclical rule or Euler s chain rule, is a formula which relates partial derivatives of three interdependent variables. The rule finds application in… …   Wikipedia

  • Selection rule — In physics and chemistry, especially in the context of quantum mechanics, a selection rule is a condition constraining the physical properties of the initial system and the final system that is necessary for a process to occur with a nonzero… …   Wikipedia

  • Exponentiation — Exponent redirects here. For other uses, see Exponent (disambiguation). Exponentiation is a mathematical operation, written as an, involving two numbers, the base a and the exponent (or power) n. When n is a positive integer, exponentiation… …   Wikipedia

  • Matrix (mathematics) — Specific elements of a matrix are often denoted by a variable with two subscripts. For instance, a2,1 represents the element at the second row and first column of a matrix A. In mathematics, a matrix (plural matrices, or less commonly matrixes)… …   Wikipedia

  • Surreal number — In mathematics, the surreal number system is an arithmetic continuum containing the real numbers as well as infinite and infinitesimal numbers, respectively larger or smaller in absolute value than any positive real number. The surreals share… …   Wikipedia

  • chemical bonding — ▪ chemistry Introduction       any of the interactions that account for the association of atoms into molecules, ions, crystals, and other stable species that make up the familiar substances of the everyday world. When atoms approach one another …   Universalium

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”