ArticleslgStudy

computer science

Greiner–Hormann clipping algorithm

Greiner–Hormann clipping algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Greiner–Hormann clipping algorithm rather than just read about it. In short: The Greiner-Hormann algorithm is used in computer graphics for polygon clipping. It performs better than the Vatti clipping algorithm, but cannot handle degeneracies.

Key takeaways

  • Greiner–Hormann clipping algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Greiner–Hormann clipping algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Greiner–Hormann clipping algorithm from memory before moving on to harder problems.

Reference excerpt

The Greiner-Hormann algorithm is used in computer graphics for polygon clipping. It performs better than the Vatti clipping algorithm, but cannot handle degeneracies. It can process both self-intersecting and non-convex polygons. It can be trivially generalized to compute other Boolean operations on polygons, such as union and difference. The algorithm is based on the definition of the "inside" of a polygon based on the winding number. It considers regions with odd winding number to be inside the polygon; this is known as the even–odd rule. It takes two lists of polygons as input. In its original form, the algorithm is divided into three phases:

In the first phase, pairwise intersections between edges of the polygons are computed. Additional vertices are inserted into both polygons at the points of intersection; an intersection vertex holds a pointer to its counterpart in the other polygon. In the second phase, each intersection is marked as either an entry intersection or an exit intersection. This is accomplished by evaluating the even–odd rule at the first vertex, which allows you to know whether the first vertex is inside or outside the other polygon. Then, following the polygon's borders, the intersections are marked with alternating flags (the next intersection after an entry intersection must be an exit intersection). In the third phase, the result is generated. The algorithm starts at an unprocessed intersection and picks the direction of traversal based on the entry/exit flag: for an entry intersection it traverses forward, and for an exit intersection it traverses in reverse. Vertices are added to the result until the next intersection is found; the algorithm then switches to the corresponding intersection vertex in the other polygon and picks the traversal direction again using the same rule. If the next intersection has already been processed, the algorithm finishes the current component of the output and starts again from an unprocessed intersection. The output is complete when there are no more unprocessed intersections. The algorithm is not restricted to polygons and can handle arbitrary parametric curves as segments, as long as there is a suitable pairwise intersection procedure. A major shortcoming of the original Greiner–Hormann algorithm is the fact that it cannot handle degeneracies, such as common edges or intersections exactly at a vertex. The original paper suggests perturbing the vertices to remove them.

See also Vatti clipping algorithm Sutherland–Hodgman clipping algorithm Weiler–Atherton clipping algorithm Boolean operations on polygons

References

External links Geographic Clipping Describes the clipping algorithms in D3.js. https://github.com/helderco/univ-polyclip An implementation in Python and Java. https://github.com/w8r/GreinerHormann An implementation in JavaScript JTS Topological Suite A topological suite with a Java implementation

Worked examples

Example 1 — a first encounter with Greiner–Hormann clipping algorithm

Start with the simplest possible case. Write down what Greiner–Hormann clipping algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Greiner–Hormann clipping algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Greiner–Hormann clipping algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Greiner–Hormann clipping algorithm

In research
Greiner–Hormann clipping algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Greiner–Hormann clipping algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Greiner–Hormann clipping algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer graphics stubs, Polygon clipping algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Greiner–Hormann clipping algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Greiner–Hormann clipping algorithm” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Greiner–Hormann clipping algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Greiner–Hormann clipping algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Greiner–Hormann clipping algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Greiner–Hormann clipping algorithm in simple terms?

The Greiner-Hormann algorithm is used in computer graphics for polygon clipping. It performs better than the Vatti clipping algorithm, but cannot handle degeneracies.

Why does Greiner–Hormann clipping algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Greiner–Hormann clipping algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Greiner–Hormann clipping algorithm.

Tags

  • Computer graphics stubs
  • Polygon clipping algorithms

Keep exploring