I need to fix the boundary for the available polygons how can I fix it?


red is the boundary how can I fix that so that will be the same as our current polygon.

   const getBoundary = (points: any[]) => {
      if (!points || points.length === 0) {
        return null; // Return null if no points are provided
      }

      let minX = Infinity;
      let minY = Infinity;
      let minZ = Infinity;
      let maxX = -Infinity;
      let maxY = -Infinity;
      let maxZ = -Infinity;

      points.forEach((point) => {
        minX = Math.min(minX, point.x);
        minY = Math.min(minY, point.y);
        minZ = Math.min(minZ, point.z);
        maxX = Math.max(maxX, point.x);
        maxY = Math.max(maxY, point.y);
        maxZ = Math.max(maxZ, point.z);
      });

      return {
        minX,
        minY,
        minZ,
        maxX,
        maxY,
        maxZ,
      };
    };

code for the boundary

Thanks

Your green polygon doesn’t have an associated axis frame… so this is actually a potentially really tricky problem to solve.

You could fake something up by using the first edge as the X axis… assuming 0,1,0, is up, and constructing the other axis with the normalized cross product of those 2 vectors…

The “real” solution involves something called PCA (principal component analysis) which takes in the points and figures out what the primary axis/orientation directions are.

3 Likes

can you give me a code example?


image
as you can see on the flat roof there is a direction issue and then when I change the roof type to the hip roof at the time panel is not loading perfectly can anyone please help me resolve this issue