Quote:

> > Then i want to know the X.Y between x1,y1 and x2,y2.

> > Is there a way to calculate that?

> Yepp.

> Simple way:

> y = mx + n

> with: m = delta_y / delta_x = abs(y2 - y1) / abs(x2 - x1)

> and: n = y - m * x = y1 - m * x1

> calculating:

> for x := x1 to x2 do y := m * x + n;

> What do kids learn in school today? It's basic math.

> For a fast way to calculate x,y - for example for a line drawing procedure

> - google for Bresenhams Algorithm.

> HTH Matt

There are a couple problems with this simple answer.

Doesn't work when x1=x2.

(I'll leave it to the reader to transpose the function and do things in

terms of y).

if | x2 - x1 | < | y2 - y1 | you will skip some points.

You'll get closer if you iterate over the greater gap and round the result.

Especially if you are trying to grab the individual integer-valued points

along

a rasterized line.

Rufus

Rufus V. Smith

Software/Hardware Design (esp. Automation)

Recently available for full, part-time, or contract work.

Home Page: http://members.aol.com/rufusvs

Looking for work? Check my Job Search Links.

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----

http://www.newsfeeds.com - The #1 Newsgroup Service in the World!

-----== Over 80,000 Newsgroups - 16 Different Servers! =-----