GetVelocity.emam 648 Bytes
Newer Older
Bernhard Rumpe's avatar
BR-sy    
Bernhard Rumpe committed
1
/* (c) https://github.com/MontiCore/monticore */
Jean-Marc Ronck's avatar
Jean-Marc Ronck committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package de.rwth.supermario.haller.tools;


component GetVelocity {
    ports   //x,y
    
        in Z distX,
        in Z distY,
        
        out Z velX,
        out Z velY;

    implementation Math {
        static Z oldDistX = -1;
        static Z oldDistY = -1;
        
        //Calculate velocity (distance / ticklength)
        if(oldDistX != -1)
            velX = distX - oldDistX;
            velY = distY - oldDistY;
            oldDistX = distX;
            oldDistY = distY;
            
        else
            velX = -1;
            velY = -1;
        end
        
    }
    
Bernhard Rumpe's avatar
BR-sy    
Bernhard Rumpe committed
32
}