csg_sphere: CSG Sphere

View source: R/csg_construct.R

csg_sphereR Documentation

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

if(rayrender:::run_documentation()) {
#Generate a simple sphere:
generate_ground() %>% 
  add_object(csg_object(csg_sphere(),
                        material=glossy(color="purple"))) %>% 
  render_scene(clamp_value=10)
}
if(rayrender:::run_documentation()) {
#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)
}
if(rayrender:::run_documentation()) {
#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)
}
if(rayrender:::run_documentation()) {
#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)
}
if(rayrender:::run_documentation()) {
#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 documentation built on June 8, 2023, 6:34 a.m.