Solved

How to extend a line starting from (x0,y0) and passing thru (x1,y1) upto (xn,yn)?

Posted on 2009-04-09
4
405 Views
Last Modified: 2013-12-26
Hi,

I have one center point (x0,y0) and some more points scattered on canvas (x1,y1), (x2,y2)...
I want to show a motion of a sprite in a straight line starting from (x0,y0) thru (x1,y1) till it reaches beyond the boundary of canvas.

In fact, the sprite might be present anywhere on canvas (x1,y1/x2,y2...) and from a central reference point (x0,y0) i want to show its motion in straight line till it reaches beyond the canvas boundary.

Many line drawing (pixel-by-pixel) algorithms give coordinates from x0,y0 to x1,y1 and not beyond that, however, i want to extend that line to (xn,yn) which could be anything depending upon (x0,y0) and (x1,y1)

Any ideas?
Algorithm?
line-extend-problem.gif
0
Comment
Question by:vijaywadnere
  • 2
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 20 total points
ID: 24105167
x = X0 + (X1-X0)*t
y = Y0 + (Y1-Y0)*t
0
 

Author Comment

by:vijaywadnere
ID: 24106026
Ozo:
Though I somehow calculated the value for "t" that suits my requirements by hit-n-trial - and the value i get is t>1 & t<2 (1.09/1.1/1.2..) what exactly this value should be?
What this "t" denotes??

The formula works like charm for any pixel in any quadrant.
0
 

Author Closing Comment

by:vijaywadnere
ID: 31568427
Even though the "t" remained mystery for me, I accept this solution since I managed to get my work done with the help of the given formula.

A little explanation would have claimed a higher grade.
0
 
LVL 84

Expert Comment

by:ozo
ID: 24161132
Sory, I didn't see your question,
t goes from 0 to 1 between the points, and then beyond 1 to extend the line
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Export from Blender to ZPrint with textures 4 737
Python RTS must use TKinter? 5 459
mfc + Opengl - i am getting error 1282 13 889
How do I lock down a trademark? 11 76
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

14 Experts available now in Live!

Get 1:1 Help Now