csg_triangle: CSG Triangle

Description Usage Arguments Value Examples

View source: R/csg_construct.R

Description

CSG Triangle

Usage

1
csg_triangle(v1 = c(0, 1, 0), v2 = c(1, 0, 0), v3 = c(-1, 0, 0))

Arguments

v1

Default 'c(0,1,0)'. First vertex.

v2

Default 'c(1,0,0)'. Second vertex.

v3

Default 'c(-1,0,0)'. Third vertex.

Value

List describing the triangle in the scene.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#Generate a basic triangle:
generate_ground(material=diffuse(checkercolor="grey20")) %>% 
  add_object(csg_object(csg_triangle(),material=diffuse(color="red"))) %>% 
  add_object(sphere(y=5,z=3,material=light(intensity=30))) %>% 
  render_scene(clamp_value=10,fov=20)
  
#Change a vertex:
generate_ground(material=diffuse(checkercolor="grey20")) %>% 
  add_object(csg_object(csg_triangle(v1 = c(1,1,0)),material=diffuse(color="green"))) %>% 
  add_object(sphere(y=5,z=3,material=light(intensity=30))) %>% 
  render_scene(clamp_value=10,fov=20)
  
#Change all three vertices:
generate_ground(material=diffuse(checkercolor="grey20")) %>% 
  add_object(csg_object(csg_triangle(v1 = c(0.5,1,0), v2 = c(1,-0.5,0), v3 = c(-1,0.5,0)),
                        material=diffuse(color="blue"))) %>% 
  add_object(sphere(y=5,z=3,material=light(intensity=30))) %>% 
  render_scene(clamp_value=10,fov=20,lookfrom=c(0,5,10))

rayrender documentation built on April 7, 2021, 5:06 p.m.