Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

csg_cylinder

CSG Cylinder


Description

CSG Cylinder

Usage

csg_cylinder(
  start = c(0, 0, 0),
  end = c(0, 1, 0),
  radius = 1,
  corner_radius = 0
)

Arguments

start

Default 'c(0, 0, 0)'. Start point of the cylinder, specifing 'x', 'y', 'z'.

end

Default 'c(0, 1, 0)'. End point of the cylinder, specifing 'x', 'y', 'z'.

radius

Default '1'. Cylinder radius.

corner_radius

Default '0'. Radius if rounded cylinder.

Value

List describing the cylinder in the scene.

Examples

#Generate a basic cylinder:
generate_ground(material=diffuse(checkercolor="grey20")) %>% 
  add_object(csg_object(csg_cylinder(radius=0.25),material=glossy(color="red"))) %>% 
  render_scene(clamp_value=10,fov=20)
  
#Change the orientation by specifying a start and end
generate_ground(material=diffuse(color="dodgerblue4",checkercolor="grey10")) %>% 
  add_object(csg_object(csg_cylinder(start = c(-1,0.5,-2), end = c(1,0.5,-2),
    radius=0.5),material=glossy(checkercolor="red"))) %>% 
  render_scene(clamp_value=10,fov=20,
               lookat=c(0,0.5,-2),lookfrom=c(3,3,10))
 
#Show the effect of changing the radius
generate_ground(material=diffuse(color="dodgerblue4",checkercolor="grey10")) %>% 
  add_object(csg_object(
    csg_combine(
    csg_cylinder(start = c(-1,0.5,-2), end = c(1,0.5,-2), radius=0.5),
    csg_cylinder(start = c(-0.5,1.5,-2), end = c(0.5,1.5,-2), radius=0.25)),
    material=glossy(checkercolor="red"))) %>% 
  render_scene(clamp_value=10,fov=20,
               lookat=c(0,0.5,-2),lookfrom=c(-3,3,10))
               
#Render a red marble cylinder in a Cornell box
generate_cornell(light=FALSE) %>% 
  add_object(csg_object(
    csg_cylinder(start = c(555/2,0,555/2), end = c(555/2,350,555/2), radius=100),
    material=glossy(color="darkred",noisecolor="white",noise=0.03))) %>% 
    add_object(sphere(y=555,x=5,z=5, radius=5,
               material=light(intensity=10000,
                              spotlight_focus = c(555/2,555/2,555/2),spotlight_width = 45))) %>% 
  render_scene(clamp_value=4)

rayrender

Build and Raytrace 3D Scenes

v0.21.2
GPL-3
Authors
Tyler Morgan-Wall [aut, cph, cre] (<https://orcid.org/0000-0002-3131-3814>), Syoyo Fujita [ctb, cph], Melissa O'Neill [ctb, cph], Vilya Harvey [ctb, cph]
Initial release
2021-04-01

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.