Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

2.2 Cyrus-Beck Parametric Line Clipping

Lesson 11 of 32 in the free Computer Graphics notes on Siksha Sarovar, written by Rohit Jangra.

Why Another Clipper

Cohen-Sutherland is restricted to axis-aligned rectangles. Cyrus-Beck clips a line against any convex polygon (including the rectangular window) by working in parametric form.

Parametric Setup

Represent the line as P(t) = P0 + t * (P1 - P0), with t in [0, 1] giving the visible segment of an unclipped line.

For each edge i of the convex window with an outward (or inward, with consistent sign) normal N_i and a point F_i on the edge: N_i . (P(t) - F_i) = 0 -> t_i = (N_i . (F_i - P0)) / (N_i . D), where D = P1 - P0.

Classification (using inward normals N_i)

  • If N_i . D > 0: the line is going from outside to inside as t increases -> PE (potentially entering).
  • If N_i . D < 0: from inside to outside -> PL (potentially leaving).
  • If N_i . D = 0: parallel; check sign of N_i . (F_i - P0): if negative, line is on outside side of this edge -> reject; else this edge does not constrain.

Compute t_E and t_L

  • t_E = max(0, max(t_i over all PE edges)).
  • t_L = min(1, min(t_i over all PL edges)).

If t_E > t_L: the line misses the window (reject). Else clipped segment is from P(t_E) to P(t_L).

Worked Sketch

Convex pentagon window with edges E1..E5. Line from P0(-3, 0) to P1(7, 5). Compute D = (10, 5). For each edge, compute t_i and tag as PE or PL. Suppose t_E = 0.3 and t_L = 0.85; then visible segment runs from P(0.3) = (0, 1.5) to P(0.85) = (5.5, 4.25).

Comparison

AspectCohen-SutherlandCyrus-Beck
Window shapeAxis-aligned rectAny convex polygon
FormRegion codesParametric
Best trivial caseBoth endpoints same outside halfReject if t_E > t_L
GeneralityLowerHigher

Liang-Barsky Note

Liang-Barsky is the special case of Cyrus-Beck for axis-aligned rectangles, written with simple inequalities x_min <= x <= x_max etc. It is generally faster than Cohen-Sutherland for non-trivial cases because of fewer branches.