471,312 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,312 software developers and data experts.

How can I determine if a point is a given distance from a secondpoint?

I am writing a drawing program but I want to keep the scale down
(there could end up being several hundred objects on the screen).

I want to limit the points collected to a certain distance from other
points already collected, in other words, if you're drawing a line it
will only record points on the line every 6 pixels. How do I determine
how far away one point is from another? if they are restricted to
straight lines that's fine but as soon as they draw at an angle I'm
faced with determining how far away one point is from another in co-
ordinate space.

Any help would be appreciated.

Tom P.
Mar 31 '08 #1
6 1572
On Mar 31, 1:24 pm, "Tom P." <padilla.he...@gmail.comwrote:
I am writing a drawing program but I want to keep the scale down
(there could end up being several hundred objects on the screen).

I want to limit the points collected to a certain distance from other
points already collected, in other words, if you're drawing a line it
will only record points on the line every 6 pixels. How do I determine
how far away one point is from another? if they are restricted to
straight lines that's fine but as soon as they draw at an angle I'm
faced with determining how far away one point is from another in co-
ordinate space.

Any help would be appreciated.

Tom P.
Point x = new Point(1, 2);
Point y = new Point(3, 4);
double distance = Point.Distance(x, y);

I hope that helps.

goodluck,
-tom
Mar 31 '08 #2
On Mar 31, 1:58 pm, thomasnguyencom <thomasnguyen...@gmail.comwrote:
On Mar 31, 1:24 pm, "Tom P." <padilla.he...@gmail.comwrote:
I am writing a drawing program but I want to keep the scale down
(there could end up being several hundred objects on the screen).
I want to limit the points collected to a certain distance from other
points already collected, in other words, if you're drawing a line it
will only record points on the line every 6 pixels. How do I determine
how far away one point is from another? if they are restricted to
straight lines that's fine but as soon as they draw at an angle I'm
faced with determining how far away one point is from another in co-
ordinate space.
Any help would be appreciated.
Tom P.

Point x = new Point(1, 2);
Point y = new Point(3, 4);
double distance = Point.Distance(x, y);

I hope that helps.

goodluck,
-tom
You're kidding? All the crap I went through and it's already a
framework method? I could choke myself.

Thank you very much. I'm sorry I didn't look harder.

Tom P.
Mar 31 '08 #3
On Mar 31, 2:58*pm, thomasnguyencom <thomasnguyen...@gmail.comwrote:
On Mar 31, 1:24 pm, "Tom P." <padilla.he...@gmail.comwrote:
I am writing a drawing program but I want to keep the scale down
(there could end up being several hundred objects on the screen).
I want to limit the points collected to a certain distance from other
points already collected, in other words, if you're drawing a line it
will only record points on the line every 6 pixels. How do I determine
how far away one point is from another? if they are restricted to
straight lines that's fine but as soon as they draw at an angle I'm
faced with determining how far away one point is from another in co-
ordinate space.
Any help would be appreciated.
Tom P.

Point x = new Point(1, 2);
Point y = new Point(3, 4);
double distance = Point.Distance(x, y);

I hope that helps.

goodluck,
-tom
If the distance cutoff is constant you're going to be executing this
many times or for many points you might want to do the math manually
and then compare against distance squared instead e.g. distance^2 =
(x2-x1)^2 + (y2-y1)^2
Mar 31 '08 #4
On Mar 31, 1:58 pm, thomasnguyencom <thomasnguyen...@gmail.comwrote:
On Mar 31, 1:24 pm, "Tom P." <padilla.he...@gmail.comwrote:
I am writing a drawing program but I want to keep the scale down
(there could end up being several hundred objects on the screen).
I want to limit the points collected to a certain distance from other
points already collected, in other words, if you're drawing a line it
will only record points on the line every 6 pixels. How do I determine
how far away one point is from another? if they are restricted to
straight lines that's fine but as soon as they draw at an angle I'm
faced with determining how far away one point is from another in co-
ordinate space.
Any help would be appreciated.
Tom P.

Point x = new Point(1, 2);
Point y = new Point(3, 4);
double distance = Point.Distance(x, y);

I hope that helps.

goodluck,
-tom
On second thought... no it doesn't help.

I'm not finding that static method. Am I missing a namespace or
something?

Tom P.
Mar 31 '08 #5
On Mar 31, 2:15 pm, Israel <israeldip...@hotmail.comwrote:
On Mar 31, 2:58 pm, thomasnguyencom <thomasnguyen...@gmail.comwrote:
On Mar 31, 1:24 pm, "Tom P." <padilla.he...@gmail.comwrote:
I am writing a drawing program but I want to keep the scale down
(there could end up being several hundred objects on the screen).
I want to limit the points collected to a certain distance from other
points already collected, in other words, if you're drawing a line it
will only record points on the line every 6 pixels. How do I determine
how far away one point is from another? if they are restricted to
straight lines that's fine but as soon as they draw at an angle I'm
faced with determining how far away one point is from another in co-
ordinate space.
Any help would be appreciated.
Tom P.
Point x = new Point(1, 2);
Point y = new Point(3, 4);
double distance = Point.Distance(x, y);
I hope that helps.
goodluck,
-tom

If the distance cutoff is constant you're going to be executing this
many times or for many points you might want to do the math manually
and then compare against distance squared instead e.g. distance^2 =
(x2-x1)^2 + (y2-y1)^2
This is what I'm going to be using. I'll just do the math myself. I
never did find the method referred to, I don't know where tom got it
but he's got me beat.

Thanks for the help guys.

Tom P.
Mar 31 '08 #6

"Tom P." <pa***********@gmail.comwrote in message
news:bc**********************************@s13g2000 prd.googlegroups.com...
On Mar 31, 1:58 pm, thomasnguyencom <thomasnguyen...@gmail.comwrote:
>On Mar 31, 1:24 pm, "Tom P." <padilla.he...@gmail.comwrote:
I am writing a drawing program but I want to keep the scale down
(there could end up being several hundred objects on the screen).
I want to limit the points collected to a certain distance from other
points already collected, in other words, if you're drawing a line it
will only record points on the line every 6 pixels. How do I determine
how far away one point is from another? if they are restricted to
straight lines that's fine but as soon as they draw at an angle I'm
faced with determining how far away one point is from another in co-
ordinate space.
Any help would be appreciated.
Tom P.

Point x = new Point(1, 2);
Point y = new Point(3, 4);
double distance = Point.Distance(x, y);

I hope that helps.

goodluck,
-tom

On second thought... no it doesn't help.

I'm not finding that static method. Am I missing a namespace or
something?

Tom P.
Distance between (x1,y1) and (x2,y2)
= sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))

(Pythagoras's theorem).
Apr 1 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by some one | last post: by
15 posts views Thread by michael.mcgarry | last post: by
13 posts views Thread by softwaredoug | last post: by
39 posts views Thread by DanielJohnson | last post: by
14 posts views Thread by nw | last post: by
3 posts views Thread by pjmulla | last post: by
3 posts views Thread by illusion.admins | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.