CSG Sphere

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

# \donttest{ #Generate a simple sphere: generate_ground() %>% add_object(csg_object(csg_sphere(), material=glossy(color="purple"))) %>% render_scene(clamp_value=10,sample_method="stratified")
#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,sample_method="stratified")
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .
#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,sample_method="stratified")
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .
#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,sample_method="stratified")
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .
#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,sample_method="stratified")
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .
# }