CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Drawing the line on graphic lcd without endpoint coordinates

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Andrei



Joined: 26 Aug 2007
Posts: 3

View user's profile Send private message

Drawing the line on graphic lcd without endpoint coordinates
PostPosted: Sat Oct 13, 2007 3:48 am     Reply with quote

I'm wondering is it possible to create a function that draws a line on 128*64 graphic lcd, when only startpoint coordinates and the angle are known. The endpoint coordinates are unknown so in theory the line will be endless.

e.g. line(60, 40, 0.78) //startpoint X, startpoint Y, angle in radians

will draw me something like this:
Code:

--------------------------
|                  /     |
|                /       |
|              /         |
|            /           |
|                        |
|                        |
--------------------------
Ttelmah
Guest







PostPosted: Sun Oct 14, 2007 3:20 am     Reply with quote

Of course it is.
The best way, will depend on how the actual display functions are done, but (for example), one solution, it to simply plot the line to an imaginary point 'outside' the screen.
If you say that the largest line that will fit on the screen, is the diagonal of the screen, for your display, 143 pixels, then you can generate an 'imaginary' endpoint, by taking sin(theta)*143, and cos(theta)*143, adding these to the initial X and y coordinates, and using the resulting points, as the required 'endpoints' for the line to plot.
There are lots of alternative approaches (for example, taking the sin and cos, and working out which 'quadrant' the line would sit in, and then extrapolating it just to the edge of the screen), but generally line drawing algorithms using the Bressenham algorithm, will efficiently handle the line going off the screen, so the simple approach will work quite well.
Obviously, you can change the sign of the sin/cos results, and which value they are added to, to change where the effective 'origin' is for the angular measures.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group