More Subdivision, checking connections

More work on the subidivion code - now also keeping track of what shape is connected to what. Easy way to do this is to see if the points from each rectangle lie within the others. A (O(n^2)) approach, but I don't expect the number of rectangles to go beyond a few dozen so its alright for now.

Easy way to check if a point is in a rectangle:

P is the point
P1 is a corner of the rectangle (the other corders are P2, p3, p4)
V1 and V2 are the two vectors that define the sides (i.e vector from P1 to P2, and from P4 to p1)
V = is the vector P to P1

Then P is in the rectangle if
0<=dot_product(v,v1)<=dot_product(v1,v1) and 0<=dot_product(v,v2)<=dot_product(v2,v2)


Comments

Popular Posts