Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 981613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:34:13+00:00 2026-05-16T04:34:13+00:00

I am working with a Microchip dsPIC33FJ128GP802. It’s a small DSP-based microcontroller, and it

  • 0

I am working with a Microchip dsPIC33FJ128GP802. It’s a small DSP-based microcontroller, and it doesn’t have much power (40 million instructions per second). I’m looking for a way to render a convex (i.e. simple) polygon. I am only dealing with 2D shapes, integer math, and set or clear pixels (i.e. 1 bit per pixel.) I already have routines for drawing fast horizontal and vertical lines (writing up to 16 pixels in 88 cycles), so I would like to use a scanline algorithm.

However, all the algorithms I have found seem to depend on division (which takes 18 cycles on this processor) and floating point math (which is emulated in software and so is very slow; it also takes up a lot of ROM), or assume that I have a large amount of memory. I only have 2K left, ~14K is used for graphics RAM of my 16K. So does anyone know of any good, embedded machine algorithms they can point me to with a simple C or pseudocode implementation which I can implement in assembly? Preferably on the ‘net, I don’t live near any good bookstores with many programming books.

Thanks. 🙂

EDIT: Clarification, this is a polygon filling algorithm I’m looking for. I can implement a polygon outline algorithm using Bresenham’s line drawing algorithm (as Marc B suggests.)

EDIT #2: I wanted to let everyone know I got a basic algorithm up in Python. Here’s a link to the code. Public domain code.

http://dl.dropbox.com/u/1134084/bresenham_demos.py

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:34:13+00:00Added an answer on May 16, 2026 at 4:34 am

    How about Bresenham’s Line algorithm? After some setup, it’s pure integer math, and can be adapted to draw a polygon by simple iteration of starting points along the polygon edges.

    comments followup:

    I’ll try to draw this in ASCII, but it’ll probably look like crud. Bresenham’s can be used to draw a filled polygon by picking a starting edge, and iteratively moving a bresenham line across the canvas parallel to that point.

    Let’s say you’ve got some points like this:

    *(1)
                          *(3)
    
        *(2)         
                     *(4)
    

    These are numbered in left-right sort priority, so you pick the left-most starting point (1) and decide if you want to go vertically (start 1,2) or horizontally (1,3). That’d probably depend on how your DSP does its display, but let’s go with vertical.

    So… You use the 1-2 line as your starting bresenham line. You calculate the starting points of your fill lines by using lines 1-3 and 2-4 as your start/end points. Start a bresenham calculation for each, and draw another Bresenham between those two points. Kinda like:

    1.1 -> 2.1, then 1.2 -> 2.2, then 1.3 -> 2.3
    

    etc… until you reach the end of either of those lines. In this case, that’d be when the lower starting point reaches (4). At that point, you start iterating up the 4,3 line, until you reach point 3 with both starting points, and you’re done.

    *-------
     \\\\\\\\              *
      \\\\\\\\ 
       *-----\\         
             -------  *
    

    Where the dashes are the starting points you calculated along 1-3 and 2-4, and the slashes are the fill lines.

    Of course, this only works if the points are properly sorted, and you’ve got a convex polygon. If it’s concave, you’ll have to be very careful to not let your fill lines cross over the border, or do some pre-processing and subdivide the original poly into two or more convex ones.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a small game using an HTML5 canvas, and javascript. And it's working
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
Working with a Lucene index, I have a standard document format that looks something
Working in Scala-IDE, I have a Java library, in which one of the methods
Working on a multi-tenant app where most of my models will have a tenant_id
I have a question regarding stepper motor control while using the Microchip TCP/IP stack.
Working with some basic java apps on CentOS 5 linux and I have my
Working on Ubuntu 10.04 Lucid webserver (linode). Followed these instructions to install wkhtmltopdf link
Working live URL showing problem: http://69.24.73.172/demos/newDemo/test.html The HTML : <div class="small-vote"> <a href="#" class="s
working on an old translation sample code for windows phone 7. Recently, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.