FirstLineIntersection.emam 793 Bytes
Newer Older
1
2
package ba.intersection;

3
4
//Finds the earliest line intersection from a set of LineIntersection components
component FirstLineIntersection{
5
6
7
8
    ports in B collisionIn[10],
          in Q^{2,1} pointsIn[10],

          out B collisionOut,
9
10
          out Z linexA,
          out Z linexB,
11
12
13
14
15
16
17
18
19
20
          out Q^{2,1} pos;

    implementation Math{
        Z k = 1;
        B found = False;

        for i = 1:4
            for j = i:4
                if found == False
                    if collisionIn(k)
21
22
                        linexA = i;
                        linexB = j;
23
24
25
26
27
28
29
30
31
32
33
34
                        pos = pointsIn(k);
                        found = True;
                    end
                    k = k + 1;
                end
            end
        end

        collisionOut = found;
    }

}