Distance Calculation in TCL

  • Distance between nodes in Wireless network is calculated using the following formula:

    Node0-x coordinates and y coordinates
    set xx(0) 230,set yy(0) 250
    Node1-x coordinates and y coordinates
    set xx(1) 230,set yy(1) 250
    Distance between 2 nodes =
    set dx [expr $xx(0) – $xx(1)]
    set dy [expr $yy(0) – $yy(1)]
    set dx2 [expr $dx * $dx]
    set dy2 [expr $dy * $dy]
    set h2 [expr $dx2 + $dy2]
    set h(0-1) [expr pow($h2, 0.5)]
    where,
    h(0-1) → represents the distance between node0 and node1