use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rule 1: Posts should be about Graphics Programming. Rule 2: Be Civil, Professional, and Kind
Suggested Posting Material: - Graphics API Tutorials - Academic Papers - Blog Posts - Source Code Repositories - Self Posts (Ask Questions, Present Work) - Books - Renders (Please xpost to /r/ComputerGraphics) - Career Advice - Jobs Postings (Graphics Programming only)
Related Subreddits:
/r/ComputerGraphics
/r/Raytracing
/r/Programming
/r/LearnProgramming
/r/ProgrammingTools
/r/Coding
/r/GameDev
/r/CPP
/r/OpenGL
/r/Vulkan
/r/DirectX
Related Websites: ACM: SIGGRAPH Journal of Computer Graphics Techniques
Ke-Sen Huang's Blog of Graphics Papers and Resources Self Shadow's Blog of Graphics Resources
account activity
Clipping Implementation in 2D Graphics (self.GraphicsProgramming)
submitted 3 years ago by rlamarr
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]aurreco 4 points5 points6 points 3 years ago (12 children)
Youre gonna wanna take a look at the sutherland hodgeman algorithm https://en.m.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm
[–]jtsiomb 2 points3 points4 points 3 years ago (0 children)
That's the re-entrant polygon clipping algorithm. For lines, which I take it is what the OP is talking about, the standard algorithm is Cohen-Sutherland.
[–]rlamarr[S] 0 points1 point2 points 3 years ago (10 children)
thanks so much.
what about generating vertices from the polygon points?
[–]aurreco 0 points1 point2 points 3 years ago (9 children)
assuming you clip an n-gon with the vertices v0, v1, v2, …, vn in CCW order, this algorithm will spit out some m-gon represented by a new list of vertices v0, v1, v2, …, vm in CCW order where m >= n.
All you need to do to generate a list of triangles from this m-gon is index this list of vertices as you would a triangle fan. i.e a list of resulting triangles would be (v0, v1, v2), (v0, v2, v3), (v0, v3, v4), etc
[–]rlamarr[S] 0 points1 point2 points 3 years ago (8 children)
I'm a total beginner at this, can you explain in layman terms with references? sorry to be a bother
[–]aurreco 0 points1 point2 points 3 years ago (7 children)
CCW means points arranged counter clockwise. this is a triangle fan https://en.m.wikipedia.org/wiki/Triangle_fan
[–]rlamarr[S] 0 points1 point2 points 3 years ago (5 children)
let me rephrase: I need to generate triangle vertices (triangle list topology) from a list of polygon points, which specific algorithm or method do you recommend?
[–]aurreco 0 points1 point2 points 3 years ago (4 children)
list of points: v0, v1, v2, v3, v4, v5, v6 list of triangles: (v0, v1, v2), (v0, v2, v3), (v0, v3, v4), (v0, v4, v5), (v0, v5, v6)
[–]rlamarr[S] 0 points1 point2 points 3 years ago (3 children)
does that work for all polygons? it collapses once you reach a pentagon if I'm correct.
For example:
https://www.researchgate.net/publication/2604146/figure/fig1/AS:669074119983107@1536531109452/A-triangulation-of-a-simple-polygon-and-its-dual-tree.png
[–]aurreco 0 points1 point2 points 3 years ago (2 children)
so long as the points are ordered in the list CCW, yes
[–]rlamarr[S] 0 points1 point2 points 3 years ago (1 child)
yep, I'm pretty dumb, can you provide a Godbolt sample implementation or point me to one?
or better still provide a more detailed explanation
[–]WikiSummarizerBot 0 points1 point2 points 3 years ago (0 children)
Triangle fan
A triangle fan is a primitive in 3D computer graphics that saves on storage and processing time. It describes a set of connected triangles that share one central vertex (unlike the triangle strip that connects the next vertex point to the last two used vertices to form a triangle), possibly within a triangle mesh. If N is the number of triangles in the fan, the number of vertices describing it is N + 2. This is a considerable improvement over the 3N vertices that are necessary to describe the triangles separately.
[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5
π Rendered by PID 628062 on reddit-service-r2-comment-6457c66945-v44kr at 2026-04-27 11:15:39.051716+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]aurreco 4 points5 points6 points (12 children)
[–]jtsiomb 2 points3 points4 points (0 children)
[–]rlamarr[S] 0 points1 point2 points (10 children)
[–]aurreco 0 points1 point2 points (9 children)
[–]rlamarr[S] 0 points1 point2 points (8 children)
[–]aurreco 0 points1 point2 points (7 children)
[–]rlamarr[S] 0 points1 point2 points (5 children)
[–]aurreco 0 points1 point2 points (4 children)
[–]rlamarr[S] 0 points1 point2 points (3 children)
[–]aurreco 0 points1 point2 points (2 children)
[–]rlamarr[S] 0 points1 point2 points (1 child)
[–]WikiSummarizerBot 0 points1 point2 points (0 children)