Private API

Documentation of all the code not explicitly exported by module Raytracer.jl.

Contents

Private API

Raytracer.CompositeShapeType
CompositeShape <: Shape

Abstract type representing a Shape composed of other shapes.

These shapes cannot be easily described as transformed versions of a unitary shape, and so they differ from SimpleShape under many aspects.

See also: CSG

source
Raytracer.SimpleShapeType
SimpleShape <: Shape

Abstract type representing a Shape that can be represented as transformed unitary shapes.

An example of simple shape is the parallelepiped: every instance of this shape can be transformed back into a cube of unitary size. Therefore, these shapes are univocally determined by their type (e.g. a cuboid) and the transformation that morphs the unitary shape in the desired shape.

See also: Cube, Cylinder, Plane, Sphere

source
Base.:*Method
*(p::Point, s...)

Multiplication operator. x * y * z * ...calls this function with all arguments, i.e.*(x, y, z, ...)`.

Return a Point.

Examples

julia> Point(1, 2, 3) * 2 * 3
Point with eltype Float32
x = 6.0, y = 12.0, z = 18.0
source
Base.:*Method
*(c1::RGB, c2::RGB)

Return the elementwise product of two colors.

Examples

julia> RGB(1f0, 2f0, 3f0) * RGB(4f0, 5f0, 6f0)
RGB color with eltype Float32
R: 4.0, G: 10.0, B: 18.0
source
Base.:*Method
*(t::Transformation, r::Ray)

Transform a Ray with the given Transformation.

Examples

julia> ray = Ray(ORIGIN, VEC_X)
Ray
 ↳ origin = Point(0.0, 0.0, 0.0)
 ↳ dir    = Vec(1.0, 0.0, 0.0)
 ↳ tmin   = 1.0e-5
 ↳ tmax   = Inf
 ↳ depth  = 0

julia> Transformation() * ray
Ray
 ↳ origin = Point(0.0, 0.0, 0.0)
 ↳ dir    = Vec(1.0, 0.0, 0.0)
 ↳ tmin   = 1.0e-5
 ↳ tmax   = Inf
 ↳ depth  = 0

julia> translation(2,4,-6) * ray
Ray
 ↳ origin = Point(2.0, 4.0, -6.0)
 ↳ dir    = Vec(1.0, 0.0, 0.0)
 ↳ tmin   = 1.0e-5
 ↳ tmax   = Inf
 ↳ depth  = 0
source
Base.:*Method
*(scalar::Number, c::RGB)
*(c::RGB, scalar::Number)

Return a RGB color with each component multiplied by scalar.

Examples

julia> c = 2.0 * RGB(4f0, 5f0, 6f0)
RGB color with eltype Float32
R: 8.0, G: 10.0, B: 12.0

julia> RGB(4f0, 5f0, 6f0) * 2.0 == c
true
julia> c = 2.0 * RGB(4.0, 5.0, 6.0)
RGB color with eltype Float64
R: 8.0, G: 10.0, B: 12.0

julia> RGB(4.0, 5.0, 6.0) * 2.0 == c
true

Note that the eltype of RGB is mantained.

source
Base.:+Method
+(p::Point, v::Vec)

Return the elementwise sum between a Point and a Vec as an instance of Point.

Examples

julia> Point(1, 2, 3) + Vec(4, 5, 6)
Point with eltype Float32
x = 5.0, y = 7.0, z = 9.0
source
Base.:+Method
+(c1::RGB, c2::RGB)

Return the elementwise sum of two colors.

Examples

julia> RGB(1f0, 2f0, 3f0) + RGB(4f0, 5f0, 6f0)
RGB color with eltype Float32
R: 5.0, G: 7.0, B: 9.0
source
Base.:-Method
-(p1::Point, p2::Point)

Return the elementwise difference of two Point as an instance of Vec.

Examples

julia> Point(1, 2, 3) - Point(4, 5, 6)
Vec with eltype Float32
x = -3.0, y = -3.0, z = -3.0
source
Base.:-Method
-(p::Point, v::Vec)

Return the elementwise difference between a Point and a Vec as an instance of Point.

Examples

julia> Point(1, 2, 3) - Vec(4, 5, 6)
Point with eltype Float32
x = -3.0, y = -3.0, z = -3.0
source
Base.:-Method
-(c1::RGB, c2::RGB)

Return the elementwise difference of two colors.

Examples

julia> RGB(1f0, 2f0, 3f0) - RGB(4f0, 5f0, 6f0)
RGB color with eltype Float32
R: -3.0, G: -3.0, B: -3.0
source
Base.:==Method
==(c1::RGB, c2::RGB)

Elementwise comparison of two colors.

source
Base.:≈Method
≈(hr1::HitRecord, hr2::HitRecord)

Check if two HitRecord represent the same hit event or not.

source
Base.:≈Method
≈(p1::Point, p2::Point)

Check if two points are close.

Examples

julia> p = Point(1, 2, 3);

julia> p ≈ Point(1, 2, 3)
true

julia> p ≈ Point(0, 0, 0)
false
source
Base.:≈Method
≈(c1::RGB, c2::RGB)

Check if two colors are close.

Examples

julia> c = RGB(1f0, 2f0, 3f0) * RGB(4f0, 5f0, 6f0)
RGB color with eltype Float32
R: 4.0, G: 10.0, B: 18.0

julia> c ≈ RGB(4f0, 10f0, 18f0)
true

julia> c ≈ RGB(0f0, 0f0, 0f0)
false
source
Base.:≈Method
≈(r1::Ray, r2::Ray)

Check if two Ray represent the same ray of light or not.

source
Base.Filesystem.cpMethod
(cp::CheckeredPigment{N})(u::Float32, v::Float32) where {N}

Return the color of the surface in the given point $(u,v)$.

source
Base.intersectMethod
intersect(s1::Shape, s2::Shape; transformation::Transformation = Transformation())

Construct a IntersectionCSG with the given shapes as rbranch and lbranch repectively.

source
Base.invMethod
inv(t::Transformation)

Return the inverse Transformation.

Returns a Transformation which has the m and invm fields swapped.

Examples

```jldoctest; setup = :(using LinearAlgebra: Diagonal) julia> t = Transformation(Diagonal([1, 2, 3, 1])) 4x4 Transformation: Matrix of type StaticArrays.SMatrix{4, 4, Float32, 16}: 1.0f0 0.0f0 0.0f0 0.0f0 0.0f0 2.0f0 0.0f0 0.0f0 0.0f0 0.0f0 3.0f0 0.0f0 0.0f0 0.0f0 0.0f0 1.0f0 Inverse matrix of type StaticArrays.SMatrix{4, 4, Float32, 16}: 1.0f0 0.0f0 0.0f0 0.0f0 0.0f0 0.5f0 0.0f0 0.0f0 0.0f0 0.0f0 0.33333334f0 0.0f0 0.0f0 0.0f0 0.0f0 1.0f0

julia> inv(t) 4x4 Transformation: Matrix of type StaticArrays.SMatrix{4, 4, Float32, 16}: 1.0f0 0.0f0 0.0f0 0.0f0 0.0f0 0.5f0 0.0f0 0.0f0 0.0f0 0.0f0 0.33333334f0 0.0f0 0.0f0 0.0f0 0.0f0 1.0f0 Inverse matrix of type StaticArrays.SMatrix{4, 4, Float32, 16}: 1.0f0 0.0f0 0.0f0 0.0f0 0.0f0 2.0f0 0.0f0 0.0f0 0.0f0 0.0f0 3.0f0 0.0f0 0.0f0 0.0f0 0.0f0 1.0f0 ```

source
Base.setdiffMethod
setdiff(s1::Shape, s2::Shape); transformation::Transformation = Transformation())

Construct a DiffCSG with the given shapes as rbranch and lbranch repectively.

source
Base.setdiffMethod
setdiff(s::Shape, ss::Shape...); transformation::Transformation = Transformation())

Construct a DiffCSG between s and fuse(ss...).

source
Base.unionMethod
union(s1::Shape, s2::Shape; transformation::Transformation = Transformation())

Construct a UnionCSG with the given shapes as rbranch and lbranch repectively.

source
Base.unionMethod
union(s::Shape, ss::Shape...; transformation::Transformation = Transformation())

Construct a UnionCSG binary tree, by recursively calling union(::Shape, ::Shape).

source
Raytracer.scatter_rayMethod
scatter_ray(::DiffuseBRDF, pcg::PCG, incoming_dir::Vec, interaction_point::Point, normal::Normal, depth::Int)

Scatter a ray on the surface.

source
Raytracer.scatter_rayMethod
scatter_ray(::SpecularBRDF, pcg::PCG, incoming_dir::Vec, interaction_point::Point, normal::Normal, depth::Int)

Scatter a ray on the surface.

source
Raytracer.valid_intervalsMethod
valid_intervals(ts::Vector)

Return a Vector of Intervals describing what ranges of the t parameter are internal to the shape, given its ts hit parameters.

For the function to work correctly ts must be of even length.

source

Index