how to implement a quad tree

how to implement a quad tree based on the following cubemap

int P0 = -locationX * positionX + -locationY * positionY + locationZ * positionZ ;

If this produces a negative P0, you’ll get that error.