# How can I code a graph visibility criterion using an If-statement?

The visibility criterion can be defined as follows: two arbitrary data values $(ta , ya)$ and $(tb , yb)$ are visible to each other if any other data $(tc, yc)$ placed between them fulfills the following constraint:

$\qquad yc < (yb + ((ya - yb)((tb-tc)/(tb-ta))))$

The list is

timemagnitude =
{{13.801, 1.03}, {35.6257, 1.67}, {138.025, 2.21}, {149.743, 1.65}, {254.24, 2.29},
{257.262, 1.77}, {366.407, 1.49}, {369.419, 1.5}, {438.116, 2.28}, {522.69, 1.98},
{529.661, 1.43}, {576.86, 1.76}, {584.129, 1.16}, {592.416, 1.74}, {614.998, 1.71}}


How is it possible to implement my criterion using If?

I have use this but not work with criterion. Because this code work with list

l = {{1.03, 1.67, 2.21, 1.65, 2.29, 1.77, 1.49, 1.5, 2.28, 1.98}}

fiedif[m_, n_, data_] :=
If[(Min[#[[m]], #[[n]]] > Max[#[[m + 1 ;; n - 1]]])& @ data,
m \[DirectedEdge] n]

edgesSd[l_] :=
edgesSd[l] =
Cases[
Flatten[Table[fiedif[m, n, #], {m, Length[#]}, {n, m + 1, Length[#]}]],
_ \[DirectedEdge] _] & /@ l


I'm not entirely sure I understand your question, but perhaps you can reply with clarifications to this answer. You have a boolean function, let's call it visible which returns True or False depending on the input of three 2D points:

visible[a_, b_, c_] := Module[{ya, yb, yc, ta, tb, tc},
{ta, ya} = a;
{tb, yb} = b;
{tc, yc} = c;
yc < (yb + ((ya - yb) ((tb - tc)/(tb - ta))))
]


To visualize this, you can write a simple Manipulate which shows that visible is going to be either True or False depending on what side of the line through a and b it lies:

Manipulate[
Graphics[{
{Black, AbsoluteThickness[3], InfiniteLine[{a, b}]},
{Green, Opacity[.5],
HalfPlane[{a, b}, RotationTransform[\[Pi]/2][a - b]]},
{Red, Opacity[.5],
HalfPlane[{a, b}, RotationTransform[\[Pi]/2][b - a]]},
Text["a", a + .2],
Text["b", b + .2],
Text["c", c + .2]
},
PlotRange -> 4, Axes -> True,
PlotLabel -> Style[visible[a, b, c], 24, Bold]
],
{{a, {-1, 2}}, Locator},
{{b, {2, -3}}, Locator},
{{c, {3, 3}}, Locator}]


For example, here c lies on the side where visible returns False:

And here is an example where c lies on the side where visible returns True:

So then you should be able to use this boolean visible function directly in any If statement, like so:

If[
visible[a,b,c]
,
(* do something for c being visible *)
,
(* do something for c being invisible *)
]


(But I feel like I don't fully understand your question and code, so maybe you can clarify a bit more?)

• Thanks for help, Arnoud Buzing. Mar 4 '16 at 15:02