Skip to content

Commit

Permalink
Adding tessalation for Adam
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Jul 30, 2024
1 parent 92f2826 commit 70c3c23
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/main/java/eu/mihosoft/vrl/v3d/CSG.java
Original file line number Diff line number Diff line change
Expand Up @@ -2893,4 +2893,46 @@ public CSG syncProperties(CSG dying) {
getStorage().syncProperties(dying.getStorage());
return this;
}
public static List<CSG> tesselate(CSG incoming,int xSteps, int ySteps, double xGrid, double yGrid, double oddRowYOffset){
ArrayList<CSG> back = new ArrayList<CSG>();
for(int i=0;i<xSteps;i++) {
for(int j=0;j<ySteps;j++) {
double yoff = i%2==0?0:oddRowYOffset;
back.add(incoming.move(((double)i)*xGrid,yoff+(((double)j)*yGrid), 0));
}
}
return back;
}
public static List<CSG> tesselate(CSG incoming,int xSteps, int ySteps, double oddRowYOffset){
return tesselate(incoming,xSteps,ySteps,incoming.getTotalX(),incoming.getTotalY(),oddRowYOffset);
}
public static List<CSG> tesselate(CSG incoming,int xSteps, int ySteps){
return tesselate(incoming,xSteps,ySteps,incoming.getTotalX(),incoming.getTotalY(),0);
}
public static List<CSG> tesselate(CSG incoming,int steps){
return tesselate(incoming,steps,steps,incoming.getTotalX(),incoming.getTotalY(),0);
}
/**
*
* @param incoming Hexagon (with flats such that Y total is flat to flat distance)
* @param xSteps number of steps in X
* @param ySteps number of steps in Y
* @param spacing the amount of space between each hexagon
* @return a list of spaced hexagons
*/
List<CSG> tesselateHex(CSG incoming,int xSteps, int ySteps, double spacing){
double y= incoming.getTotalY()+spacing;
double x =(((y/Math.sqrt(3))))*(3/2);
return tesselate(incoming,xSteps,ySteps,x,y,y/2);
}
/**
*
* @param incoming Hexagon (with flats such that Y total is flat to flat distance)
* @param xSteps number of steps in X
* @param ySteps number of steps in Y
* @return a list of spaced hexagons
*/
List<CSG> tesselateHex(CSG incoming,int xSteps, int ySteps){
return tesselateHex(incoming, xSteps, ySteps, 0);
}
}

0 comments on commit 70c3c23

Please sign in to comment.