Solved

Scan line algorithm

Posted on 1997-04-12
3
1,083 Views
Last Modified: 2012-06-22
I think this is really easy, however, since I'm gonna be pretty specific, I'm givin' it 100 pts... ;-)

Anyway.... this is an ALGORITHM question not c++, but I couldn't find a better spot for it (and I'm using c++).

SO:  I need an algorithm that will take a CONVEX polygon and convert it to scan lines.  The polygon is described by its vertices in CW or CCW order.  (This is used in a real-time 3D renderer, so I need speed).  I've got a working version, but it's not fast enough.

I've searched all over the net, and even found some AMBIGUOUS pseudocode of the "active-edge" algorithm, but always missing SOME details.

So, all I want is a better (read quicker) algorithm than the one I'm using.  If you can give me an algorithm or point me to one which I can use, you win!  :-)

Thank you in advance,

   --- Oren
0
Comment
Question by:oren020997
3 Comments
 

Expert Comment

by:yangjun
Comment Utility
I once programmed the BGI driver for SuperVGA several years ago and came across such problems. I remembered that there was a book discussing this stuff. It gave both C and assembly routines. I forgot the name. I remembered that it talked about graphics programming in EGA and VGA graphics mode.
0
 
LVL 4

Expert Comment

by:marko020397
Comment Utility
I have had the similar problem. One of the problems in my case
was determining start and end point of scan line. To determine
these point i used the adjusted algorithms for drawing lines.
These algorithms are very fast. You just have to find them.
As I remember this approach gave me some speed up.

If you are programming 3D or any other computer graphics then
you should read the book "Computer Graphics Principles And
Practice", Addison Wessley, 1990. The authors are: James D.
Foley, Andries van Dam, Steven K. Fenier, John F, Hughes. This
is the best book on computer graphics I have ever seen.

Marko

0
 

Accepted Solution

by:
aleroy earned 100 total points
Comment Utility
The book Computer Graphics from Folley/Vandam is indeed
an excellent book ! If you are interessed in the subject, buy it !
In fact in this book, you will find everything you want to know
in section 3.5 (page 94 in the french version) about polygon filling.

Please fell free to reject the answer if you prefer an algorithm.
I don't have enough time to extract one from the book
(it is quite complex but very fast).


0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now