2
$\begingroup$

This works:

RegionIntersection[Line[{{0, 0}, {1, 1}}], Circle[{0, 0}, 0.6`, {30 °, 80 °}]]

returning a point:

Point[{0.424264, 0.424264}]

But this doesn't:

RegionIntersection[Arrow[{{0, 0}, {1, 1}}], Circle[{0, 0}, 0.6`, {30 °, 80 °}]]

It returns:

RegionIntersection::reg: Arrow[{{0,0},{1,1}}] is not a correctly specified region.

Any thoughts? Is this something we would like to work?

$\endgroup$
3
  • 1
    $\begingroup$ Do you have concrete examples of situations where it would be useful to be able to use Arrow as a region? $\endgroup$
    – C. E.
    Jul 9, 2017 at 18:43
  • $\begingroup$ @C.E. I was constructing the bisector of an angle of two arrows that met at vertex A. I was creating an image that shows how to do this with a ruler and a compass for my students. $\endgroup$
    – David
    Jul 9, 2017 at 21:45
  • $\begingroup$ I'd like to thank my colleagues for their excellent help. $\endgroup$
    – David
    Jul 10, 2017 at 19:15

3 Answers 3

4
$\begingroup$

You could include a special treatment for Arrow whenever it is found as an argument to RegionIntersection, so that it is converted into the corresponding Line object:

Unprotect[RegionIntersection];
RegionIntersection[OrderlessPatternSequence[Arrow[pts_], region_]] := 
    RegionIntersection[Line[pts], region]
Protect[RegionIntersection];

RegionIntersection[Arrow[{{0, 0}, {1, 1}}], Circle[{0, 0}, 0.6`, {30 °, 80 °}]]
(* Out: Point[{0.424264, 0.424264}] *)

... or in the opposite order (thanks to OrderlessPatternSequence):

RegionIntersection[Circle[{0, 0}, 0.6`, {30 °, 80 °}], Arrow[{{0, 0}, {1, 1}}]]
(* Out: Point[{0.424264, 0.424264}] *)

Honestly, however, I don't see much of a use for this apart from one-off convenience.

$\endgroup$
1
  • $\begingroup$ +1 ! i added a slightly modified version of your answer separately $\endgroup$
    – Ali Hashmi
    Jul 10, 2017 at 12:51
3
$\begingroup$

You can just use rules,e.g.:

roi = {Circle[{0, 0}, 0.6`, {30 \[Degree], 80 \[Degree]}],Arrow[{{0, 0}, {1, 1}}]}
Graphics[{roi, PointSize[0.02], Red,RegionIntersection @@ (roi /. Arrow[x__] :> Line[x])}]

enter image description here

$\endgroup$
1
  • 2
    $\begingroup$ Even simpler: just use Arrow -> Line as the replacement rule. $\endgroup$ Jul 10, 2017 at 9:33
2
$\begingroup$

a slight variant of @MarcoB 's answer (we can do without Unprotect):

roi = {Circle[{0, 0}, 0.6`, {30 \[Degree], 80 \[Degree]}], Arrow[{{0, 0}, {1, 1}}]};
SetAttributes[regInt, HoldAllComplete];
regInt[OrderlessPatternSequence[region_, arrow : Arrow[_]]] := 
RegionIntersection[region, Line @@ arrow];

Graphics[{roi, PointSize[0.02], Red, regInt @@ roi}] 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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