Code covered by the BSD License  

Highlights from
Check Whether a Point Lies Inside,Outside or On a Circle

Be the first to rate this file! 20 Downloads (last 30 days) File Size: 1.37 KB File ID: #8284
image thumbnail

Check Whether a Point Lies Inside,Outside or On a Circle

by Divakar Roy

 

12 Aug 2005 (Updated 24 Jun 2011)

Checks whether a point lies inside,outside or on a circle defined by 3 other points.

| Watch this File

File Information
Description

This program checks whether a point (x,y) lies inside,outside or on a circle defined by 3 other points.

Syntax: iscircle(X,Y,x,y), where X=[x1 x2 x3] and Y=[y1 y2 y3]. Thus, a circle can be made out of these 3 points-->(x1,y1), x2,y2)&(x3,y3).
Program checks whether point (x,y) lies inside,outside or on the circle.
ans=0 ==> lie on the circle.
ans=1 ==> lie outside the circle.
ans=-1 ==> lie inside the circle.

MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
16 Aug 2005 Jérôme My Last Name

Hi,

add these modifications to your code :

val=(x-h).*(x-h)+(y-k).*(y-k)-r*r;
result=sign(val);

This will let you check multiple points location at the same time.
Use SIGN here to avoid "if" condition.

Jérôme

29 Jan 2007 Nilimb Misal

nice work. simple and fast

Please login to add a comment or rating.
Updates
30 Aug 2005

As suggested by Jerome, i have made the modifications.
So now it works very fast.Thank you Jerome.

24 Jun 2011

Added screenshot.

Tag Activity for this File
Tag Applied By Date/Time
approximation Divakar Roy 22 Oct 2008 07:55:53
interpolation Divakar Roy 22 Oct 2008 07:55:53
circle Divakar Roy 22 Oct 2008 07:55:53
lie Divakar Roy 22 Oct 2008 07:55:53
inside Divakar Roy 22 Oct 2008 07:55:53
check Divakar Roy 22 Oct 2008 07:55:53
satisfy Divakar Roy 22 Oct 2008 07:55:53
outside Divakar Roy 22 Oct 2008 07:55:53
circle Sam 14 Jul 2011 21:13:45
circle Jolly 28 Nov 2011 23:34:01
inside Tom? 09 Feb 2012 03:58:36

Contact us at files@mathworks.com