Hey Im currently learning about geometry and vectors and was trying to build a room builder with three js.
I basicly create walls from two points (p1, p2). I draw a line and extrude the line to a rectangle. I create the rectangle by making a path of 4 points, where I offset the two points p1, p2 in the perpendicular direction (normal) of the line in both directions (right and left of the line). In code I used this pattern (Extrude = e)
e2 _______________e4 p1|______________|p2 e1|______________|e3 |
Now I noticed a weird but obvious behavior. When I draw the wall from p2 to p1 instead of p1 to p2 everything starts to rotate
e3 _______|_______e1 p2|______________|p1 e4|______________|e2
Now I wonder how to work around this behavior. I want to connect the walls to all other walls having the same points. So Im calculating the angle of all walls to get the two neighbours of the current wall, when I have multiple connections.
\ / |
Here is the issue im facing. When I want to calculate the intersection point of a wall and its neighbours, therefore I use 2 extruded points of wall1 and two of wall2, but I dont know which sides of the wall are facing each other.
I guess the actual question is how to handle a positive and negative draw direction of a line and how to get the sides facing to each other.
Any help is highly appreciated Ask for more infos please