Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Let's say I'm specifying a circular arc with the following information:

x1,y1,x2,y2,radius,direction

and that I have 2D boundaries of: minX = -5, minY = -5, maxX = 5, maxY = 5

how can i tell if the arc will go outside the boundaries?

so, for example, an arc with these values would go outside the bounds:

-4.5,0,-4.5,4,2,clockwise

in fact, it's almost entirely outside the bounds. but if I change the radius to 6, it won't. (or if I change the direction to ccw of course)

thanks for any help!!

share|improve this question
    
For your given coordinates and radius, an arc with its center at $x=-4.5$ and $y=2$ would join them. There can be two arcs. One remains within the bounds you specify and the other does not. This also turns out to be clockwise. –  Please Delete Account Mar 15 '11 at 7:20
    
i may have confused the issue. i'm talking about an arc that starts at x1,y1, and ends at x2,y2, with a radius. so in my example, radius of 2 gives me half a circle. anyway, what do you mean by "join" them? –  mix Mar 15 '11 at 7:44
    
i just mean it would connect the two points. pardon my english –  Please Delete Account Mar 15 '11 at 7:59
    
ah, so you're talking about an arc with a different radius, right? is there a formula I can use to detect whether my arc will go out of bounds? –  mix Mar 15 '11 at 8:13
    
In general, this is how you analyze. For $(x_1,y_1)$ and $(x_2,y_2)$ with a given radius, you can at most find four arcs staisfying your conditions. These correspond to the "longer" and "smaller" arcs with two symmetric centers $(x_0,y_0)$ and $(-x_0,-y_0)$. What remains is to check which of these remain in bound. I cannot think of a single formula, but only a bunch of inequalities. Though it should be easy to pick them out geometrically. In general possibility exists that there is no such arc. Just think of trying to remain within the bound by connecting the opposite vertices of the square. –  Please Delete Account Mar 15 '11 at 8:48
add comment

1 Answer

up vote 1 down vote accepted

This attempts a systematic approach:

  1. Check your two points are inside the bounds. In your example they are.
  2. Find the centre of the circular arc, which lies on the perpendicular bisector between the two points. Note that if the distance between the two points is not twice the radius then there will be two such points meaning two such centres and so two different arcs. In your example the distance is twice the radius and the centre is $(-4.5,2)$.
  3. Find the (real) points where the circle meets the extended bounds. There will be up to 2 for each bound. If there is just one then the circle touches the bound rather than going outside, so this can be ignored. In your example it meets the bounds at about $(-5,3.93649)$ and $(-5,0.0635)$ where the decimals are $(4\pm \sqrt{15})/2$.
  4. Drop any of these points which are outside the other bounds. In your example you do not drop anything so still have the two points where the circle meets the bounds.
  5. Decide on which side of the line which joins the two initial points the points on the circle and bounds lie. You could do this by looking at angle bearings from the centre of the various points. In your example, both of the two points where the circle meets the bounds lie on the clockwise side of the line.
  6. You have your answer. In your example, the clockwise arc crosses the bounds.
share|improve this answer
    
@henry: in #2, what do you mean there could be two centers? at least in how I'm doing this, my radius will always be, at smallest, half the distance between the two points. sometimes larger. but how does having a radius larger than distance/2 result in two arcs? in #3, how are you finding the values (-5,3.93649) and (-5,0.0635)? thanks! –  mix Mar 15 '11 at 20:46
    
ok, i see what you mean about two centers. in my case, i know which one i'm using as I know which of the two end points is the starting point and i know whether i'm going clockwise or counterclockwise from the start point. –  mix Mar 15 '11 at 21:11
    
does anyone know how henry calculated his values in step #3? –  mix Mar 16 '11 at 8:39
    
Since I was looking for where the circle crosses a line, I solved the simultaneous equations $x=-5$ and $(x+4.5)^2+(y-2)^2 = 2^2$ which becomes $(y-2)^2 = 15/4$ and hence my values. –  Henry Mar 16 '11 at 9:21
    
As for the two centres, if with arc end points $(-4.5,0)$ and $(-4.5,4)$, the radius had been 2.5 rather than 2, then the possible centres would be $(-6,2)$ and $(-3,2)$. Each centre would have two arcs (one clockwise and one anti-clockwise), making four in total. –  Henry Mar 16 '11 at 10:20
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.