update triangle algorithm