Calculate axis-aligned bounding box (AABB) for set of game pieces with and without an “oblique projection”.

aabb_piece(
df,
cfg = getOption("piecepackr.cfg", pp_cfg()),
envir = getOption("piecepackr.envir"),
op_scale = getOption("piecepackr.op_scale", 0),
op_angle = getOption("piecepackr.op_angle", 45),
...
)

## Arguments

df A data frame of game piece information with (at least) the named columns “piece_side”, “x”, and “y”. Piecepack configuration list or pp_cfg object, a list of pp_cfg objects, or a character vector referring to names in envir or a character vector referring to object names that can be retrieved by base::dynGet(). Environment (or named list) containing configuration list(s). How much to scale the depth of the piece in the oblique projection (viewed from the top of the board). 0 (the default) leads to an “orthographic” projection, 0.5 is the most common scale used in the “cabinet” projection, and 1.0 is the scale used in the “cavalier” projection. What is the angle of the oblique projection? Has no effect if op_scale is 0. Ignored

## Value

A named list of ranges with five named elements x, y, and z for the axis-aligned bounding cube in xyz-space plus x_op and y_op for the axis-aligned bounding box of the “oblique projection” onto the xy plane.

## Details

The “oblique projection” of a set of $$(x,y,z)$$ points onto the xy-plane is $$(x + \lambda * z * cos(\alpha), y + \lambda * z * sin(\alpha))$$ where $$\lambda$$ is the scale factor and $$\alpha$$ is the angle.

## Examples

 df_tiles <- data.frame(piece_side="tile_back", x=0.5+c(3,1,3,1), y=0.5+c(3,3,1,1),
suit=NA, angle=NA, z=NA, stringsAsFactors=FALSE)
df_coins <- data.frame(piece_side="coin_back", x=rep(4:1, 4), y=rep(4:1, each=4),
suit=1:16%%2+rep(c(1,3), each=8),
angle=rep(c(180,0), each=8), z=1/4+1/16, stringsAsFactors=FALSE)
df <- rbind(df_tiles, df_coins)

aabb_piece(df, op_scale = 0)
#> $x #> [1] 0.5 4.5 #> #>$y
#> [1] 0.5 4.5
#>
#> $z #> [1] 0.000 0.375 #> #>$x_op
#> [1] 0.5 4.5
#>
#> $y_op #> [1] 0.5 4.5 #> aabb_piece(df, op_scale = 1, op_angle = 45) #>$x
#> [1] 0.5 4.5
#>
#> $y #> [1] 0.5 4.5 #> #>$z
#> [1] 0.000 0.375
#>
#> $x_op #> [1] 0.500000 4.676777 #> #>$y_op
#> [1] 0.500000 4.676777
#>  aabb_piece(df, op_scale = 1, op_angle = -90)
#> $x #> [1] 0.5 4.5 #> #>$y
#> [1] 0.5 4.5
#>
#> $z #> [1] 0.000 0.375 #> #>$x_op
#> [1] 0.5 4.5
#>
#> \$y_op
#> [1] 0.25 4.50
#>