Skip to content

Latest commit

 

History

History
91 lines (80 loc) · 2.99 KB

File metadata and controls

91 lines (80 loc) · 2.99 KB

Algorithm

Here you can find a list of algorithms, including STCA and TCAS, that are incorporated into the simulation.

Creating planes

Startup: • Calculate and save camera bounds • Start planes generation

Plane generation: • Generate source and destination position, speeds and height • Create plane object • Assign values to plane • Make plane the child of itself

Plane life cycle

• Calculate position
• If new position is in destination:
    ◦ Destroy plane
    ◦ return
• Set position
• Calculate height
• Set height
• Set sprite, colors according to its state
• Update texts
• If camera in Dispatcher mode:
    ◦ Reset rotation
• Else:
    ◦ Set rotation the same as observed plane
• If is selected and in near collision mode:
    ◦ Call SCTA controller to take control of planes in collision

Collision detection algorithm

• Get all planes in scene
• For each plane:
    ◦ For each other planes:
        ▪ Calculate distance between planes
        ▪ If distance is less than critical:
            • If collision already exists:
                ◦ Copy existing collision into new collection
            • Else:
                ◦ Create new collision including the time of collision
        ▪ Else:
            • Do nothing
• For each old collision:
    ◦ Reset plane to normal mode
• Clear old collision list
• Set new collisions
• For each new collision:
    ◦ If plane in normal state:
        ▪ Set plane in Near collision state

Collision prevention algorithm

• Get all collisions
• For each collision:
    ◦ If collision is in SCTA controlled or not controlled:
        ▪ If timer is exceeded:
            • Change control mode to TCAS

STCA algorithm

Taking control of STCA collision: • If there is selected collision: ◦ Return collision in None mode ◦ Return planes in NearCollision mode • Save collision • If collision is valid: ◦ Change collision’s state to STCA controller and update planes’ mode ◦ Update slider values to match current height and speed of planes

Workflow:

• If collision is not set:
    ◦ Hide control canvas
    ◦ Return
• Show control canvas
• Update planes’ height and speed as slider values
• Update planes’ information on canvas
• Calculate and show the distance between planes

TCAS algorithm

• Get all collisions in TCAS mode
• For every collision:
    ◦ If not in TCAS mode:
        ▪ Continue;
    ◦ If first plane is higher than the second:
        ▪ Change the first plane’s height to dH
        ▪ Change the second plane’s height to -dH
    ◦ Else:
        ▪ Change the first plane’s height to -dH
        ▪ Change the second plane’s height to dH