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

csg_sphere

CSG Sphere


Description

CSG Sphere

Usage

csg_sphere(x = 0, y = 0, z = 0, radius = 1)

Arguments

x

Default '0'. x-coordinate of the center of the sphere.

y

Default '0'. y-coordinate of the center of the sphere.

z

Default '0'. z-coordinate of the center of the sphere.

radius

Default '1'. Radius of the sphere.

Value

List describing the sphere in the scene.

Examples

#Generate a simple sphere:
generate_ground() %>% 
  add_object(csg_object(csg_sphere(),
                        material=glossy(color="purple"))) %>% 
  render_scene(clamp_value=10)

#Generate a bigger sphere in the cornell box.
generate_cornell() %>% 
  add_object(csg_object(csg_sphere(x=555/2,y=555/2,z=555/2,radius=100),
                        material=glossy(checkercolor="purple", checkerperiod=100))) %>% 
  render_scene(clamp_value=10)
  
#Combine two spheres of different sizes
generate_cornell() %>% 
  add_object(csg_object(
    csg_combine(
      csg_sphere(x=555/2,y=555/2-50,z=555/2,radius=100),
      csg_sphere(x=555/2,y=555/2+50,z=555/2,radius=80)),
    material=glossy(color="purple"))) %>% 
  render_scene(clamp_value=10)

#Subtract two spheres to create an indented region
generate_cornell() %>% 
  add_object(csg_object(
    csg_combine(
      csg_sphere(x=555/2,y=555/2-50,z=555/2,radius=100),
      csg_sphere(x=555/2+30,y=555/2+20,z=555/2-90,radius=40),
      operation="subtract"),
    material=glossy(color="grey20"))) %>% 
  render_scene(clamp_value=10)
  
#Use csg_combine(operation="blend") to melt the two together
generate_cornell() %>% 
  add_object(csg_object(
    csg_combine(
      csg_sphere(x=555/2,y=555/2-50,z=555/2,radius=100),
      csg_sphere(x=555/2,y=555/2+50,z=555/2,radius=80),
      operation="blend", radius=20),
    material=glossy(color="purple"))) %>% 
  render_scene(clamp_value=10)

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.