Translate Lines

translate_lines(lines, position = 1)

Arguments

lines

The line scene.

position

Default `c(0,0,0)`. The translation vector.

Value

Translated line matrix.

Examples

# \donttest{
#Generate a cube out of lines
cube_outline = generate_line(start = c(-1, -1, -1), end = c(-1, -1, 1)) %>%
  add_lines(generate_line(start = c(-1, -1, -1), end = c(-1, 1, -1))) %>%
  add_lines(generate_line(start = c(-1, -1, -1), end = c(1, -1, -1))) %>%
  add_lines(generate_line(start = c(-1, -1, 1), end = c(-1, 1, 1))) %>%
  add_lines(generate_line(start = c(-1, -1, 1), end = c(1, -1, 1))) %>%
  add_lines(generate_line(start = c(-1, 1, 1), end = c(-1, 1, -1))) %>%
  add_lines(generate_line(start = c(-1, 1, 1), end = c(1, 1, 1))) %>%
  add_lines(generate_line(start = c(1, 1, -1), end = c(1, -1, -1))) %>%
  add_lines(generate_line(start = c(1, 1, -1), end = c(1, 1, 1))) %>%
  add_lines(generate_line(start = c(1, -1, -1), end = c(1, -1, 1))) %>%
  add_lines(generate_line(start = c(1, -1, 1), end = c(1, 1, 1))) %>%
  add_lines(generate_line(start = c(-1, 1, -1), end = c(1, 1, -1))) 
rasterize_lines(cube_outline,fov=40,lookfrom=c(1,2,10),lookat=c(0,0,0))
#> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): there is no package called ‘terra’

#Scale the cube uniformly
translated_cube = color_lines(translate_lines(cube_outline,c(1,1,1)),"red")
translated_cube2 = color_lines(translate_lines(cube_outline,c(-1,-1,-1)),"green")

cube_outline %>% 
  add_lines(translated_cube) %>% 
  add_lines(translated_cube2) %>% 
  rasterize_lines(fov=40,lookfrom=c(1,2,10),lookat=c(0,0,0))
#> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): there is no package called ‘terra’
  # }