| | |
Need a function which returns points X,Y in a Circle
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jun 2009
Posts: 9
Reputation:
Solved Threads: 0
Hello,
I need to create a function which takes parameters for a circle and checks if a given point(x,y) lies within the circle (or on the edge).
Like this:
Could someone help me with this?, unfortunately i'm not good at math..
Mervin.
I need to create a function which takes parameters for a circle and checks if a given point(x,y) lies within the circle (or on the edge).
Like this:
C# Syntax (Toggle Plain Text)
public static bool PointExistsInCircle(Double CircleX,Double CircleY,Double CircleRadius,Double PointX,Double PointY) { needs to return 'true' if the point is in the circle, if not return 'false'. }
Could someone help me with this?, unfortunately i'm not good at math..
Mervin.
Last edited by MervinKoops; Sep 21st, 2009 at 5:50 pm.
•
•
Join Date: Jul 2009
Posts: 920
Reputation:
Solved Threads: 147
I'm not good at math either...LOL. Check out this thread, and see if you can come up with the formula you need. Then, if you need help with coding it, come on back here--OK?
Calculate Radius from X Y coord
Calculate Radius from X Y coord
Well, the equation of a circle with radius R on the origin is 
All you have to do is test if this inequality is true or false :
If it is true the point (x,y) is in the circle, if it is equal it is on the circle, else it lies outside the circle.
It should be rather easy to write that in C#.
All you have to do is test if this inequality is true or false :
If it is true the point (x,y) is in the circle, if it is equal it is on the circle, else it lies outside the circle.
It should be rather easy to write that in C#.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
Don't know exactly what you mean here but I guess it is something like this ^2+(y-b)^2 = R^2)
Where a and b are the new coordinates of the center. If a and b are both zero then the circle has its center at the origin.
Where a and b are the new coordinates of the center. If a and b are both zero then the circle has its center at the origin.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
I don't understand the Circle X,Y, and Radius. Don't you just need a single center point and the radius, then draw the circle from there?
Last edited by sknake; Sep 21st, 2009 at 6:55 pm.
Take a look at online book at google - Physics for game programmers By Grant Palmer
•
•
•
•
SUMMARY:
Determine if the point is inside the circle by computing the distance from the point to the center of the circle. If the distance is less than 1, the point is inside.
C# Syntax (Toggle Plain Text)
double distance = Math.Sqrt((x-0.5)*(x-0.5) + (y-0.5)*(y-0.5)); if(distance<=0.5){ ... }
Failure is not fatal, but failure to change might be. - John Wooden
![]() |
Similar Threads
- Function always returns false (C++)
- regression line and loops (Python)
- COM Memory Layout, Vtable, and Function Pointer Issues And Questions (C++)
- Which C++ string function returns nth character of the string? (C++)
- Simple function (C++)
- Need help getting text to display in a graphics window (Python)
- function returns address out of bounds (C)
- Function that returns void (C++)
Other Threads in the C# Forum
- Previous Thread: Retrieving records in batches of 50
- Next Thread: Can you install apps made in VS 2008 on these OSs
| Thread Tools | Search this Thread |
algorithm angle array bitmap c# c++ conversion cuil decimal degrees development drawing enum equation form function gdi+ google grade javascript mandelbrot math mathematics method news numbers operator picturebox plotting polynomial prime primenumbersinrange radians recursive round search statistics technology time usb vb vbnet web wolframalpha






.
