473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 1666
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: some one | last post by:
Does anyone know the algorithm or a function out there that will compute the offset location given the following: inputs: 1) x,y coordinate of starting point 2) angle (bearing) 3) distance to...
15
by: michael.mcgarry | last post by:
Hi, I have a question about floating point precision in C. What is the minimum distinguishable difference between 2 floating point numbers? Does this differ for various computers? Is this...
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
13
by: softwaredoug | last post by:
I can't see to easily find this on google or in a newsgroup Is there a standard function/macro/whatever you can call and determine the distance in a C program how deep one is in the C call stack...
39
by: DanielJohnson | last post by:
I wrote a simply program with a 3 D coordinate called point. I am adding two points, taking their distance etc. gcc compiler is not identifying the struct. Here is the code. I get bunch of errors....
14
by: nw | last post by:
Hi, I'd like to compare 2 floating point numbers within a given error. I'd rather not use a absolute error but one related to the number of values that can be represented between the two floats....
3
by: pjmulla | last post by:
I am nes to python and need some help. Can anyone lead me in the right direction to create and print a Point object, and then use id to print the object's unique identifier. Translate the...
3
by: illusion.admins | last post by:
I am trying to code something to tell me if a selected point is in a particular ellipse. For the ellipse I know how it was constructed (know the x,y, and width, height). But if I just check to see...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.