Skip to content

Commit

Permalink
further documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jtramm committed Dec 15, 2016
1 parent cf2bd11 commit a95be03
Showing 1 changed file with 103 additions and 12 deletions.
115 changes: 103 additions & 12 deletions src/ConstructiveSolidGeometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,63 @@ export cross

using Plots

"An {x,y,z} coordinate type. Used throughout the ConstructiveSolidGeometry.jl package for speed."
"""
type Coord
An {x,y,z} coordinate type. Used throughout the ConstructiveSolidGeometry.jl package for speed.
# Constructors
* `Coord(x::Float64, y::Float64, z::Float64)`
# Fields
* `x::Float64`
* `y::Float64`
* `z::Float64`
"""
type Coord
x::Float64
y::Float64
z::Float64
end

"A ray is defined by its origin (Coord) and a unitized direction vector (Coord)"
"""
type Ray
A ray is defined by its origin and a unitized direction vector
# Constructors
* `Ray(origin::Coord, direction::Coord)
# Fields
* `origin::Coord`
* `direction::Coord`
"""
type Ray
origin::Coord
direction::Coord
end

"An abstract class that all surfaces (Sphere, Plane, InfCylinder) inherit from. Implementation of new shapes should inherit from this"
"""
abstract Surface
An abstract class that all surfaces (`Sphere`, `Plane`, `InfCylinder`) inherit from. Implementation of new shapes should inherit from `Surface`.
"""
abstract Surface

"A plane is defined by a point Coord on the surface of the plane, its unit normal vector Coord, and a boundary condition.
Boundary conditions are transmission (default), reflective, and vacuum"
"""
type Plane <: Surface
Defined by a point on the surface of the plane, its unit normal vector, and an optional boundary condition.
# Constructors
* `Plane(point::Coord, normal::Coord)`
* `Plane(point::Coord, normal::Coord, boundary::String)`
# Arguments
* `point::Coord`: Any point on the surface of the plane
* `normal::Coord`: A unit normal vector of the plane. Recommended to use `unitize(c::Coord)` if normalizing is needed.
* `boundary::String`: Optional boundary condition, defined as a `String`. Options are "transmission" (default), "vacuum", and "reflective".
"""
type Plane <: Surface
point::Coord
normal::Coord
Expand All @@ -63,7 +102,20 @@ type Plane <: Surface
Plane(point::Coord, normal::Coord) = new(point, normal, false, false)
end

"A sphere is defined by its center Coord, its radius, and a boundary condition (transmission or vacuum)"
"""
type Sphere <: Surface
Defined by the center of the sphere, its radius, and an optional boundary condition.
# Constructors
* `Sphere(center::Coord, radius::Float64)`
* `Sphere(center::Coord, radius::Float64, boundary::String)`
# Arguments
* `center::Coord`: The center of the sphere
* `radius::Float64`: The radius of the sphere
* `boundary::String`: Optional boundary condition, defined as a `String`. Options are \"transmission\" (default), \"vacuum\", and \"reflective\".
"""
type Sphere <: Surface
center::Coord
radius::Float64
Expand All @@ -82,7 +134,21 @@ type Sphere <: Surface
Sphere(c::Coord, r::Float64) = new(c, r, false, false)
end

"An Infinite Cylinder is defined by a Coord on its central axis, a unit direction vector Coord along its axis, its radius, and a boundary condition (transmission or vacuum)"
"""
type InfCylinder <: Surface
An arbitrary direction infinite cylinder defined by any point on its central axis, its radius, the unit normal direction of the cylinder, and an optional boundary condition. A finite cylinder can be generated by defining the intersection of an infinite cylinder and two planes.
# Constructors
* `InfCylinder(center::Coord, normal::Coord, radius::Float64)`
* `InfCylinder(center::Coord, normal::Coord, radius::Float64, boundary::String)`
# Arguments
* `center::Coord`: The center of the infinite cylinder
* `normal::Coord`: A unit normal direction vector of the cylinder (i.e., a vector along its central axis), Recommended to use `unitize(c::Coord)` if normalizing is needed.
* `radius::Float64`: The radius of the infinite cylinder
* `boundary::String`: Optional boundary condition, defined as a `String`. Options are \"transmission\" (default), \"vacuum\", and \"reflective\".
"""
type InfCylinder <: Surface
center::Coord
normal::Coord
Expand All @@ -102,19 +168,44 @@ type InfCylinder <: Surface
InfCylinder(c::Coord, n::Coord, r::Float64) = new(c, n, r, false, false)
end

"A box is axis aligned and is defined by the minimum Coord and maximum Coord of the box"
type Box <: Surface
"""
type Box
An axis aligned box is defined by the minimum `Coord` and maximum `Coord` of the box
# Constructors
* `Box(min::Coord, max::Coord)`
"""
type Box
lower_left::Coord
upper_right::Coord
end

"Defined by a surface and a halfspace (+1 or -1)"
"""
type Region
The volume that is defined by a surface and one of its halfspaces
# Constructors
* `Region(surface::Surface, halfspace::Int64)`
# Arguments
* `surface::Surface`: A `Sphere`, `Plane`, or `InfCylinder`
* `halfspace::Int64`: Either +1 or -1
"""
type Region
surface::Surface
halfspace::Int64
end

"Defined by an array of Regions and a Julia expression indicating the logical combination of regions that define the cell"
"""
type Cell
Defined by an array of Regions the logical combination of regions that define the cell
# Constructors
* `Cell(regions::Array{region}`
"""
type Cell
regions::Array{Region}
definition::Expr
Expand Down Expand Up @@ -526,7 +617,7 @@ Plots a 2D x-y slice of a geometry.
# Arguments
* `geometry::Geometry`: the geometry we want to plot
* `view::Box``: The view box is an axis aligned box that defines where the picture will be taken, with both min and max z dimensions indicating the single z elevation the slice is taken at.
* `view::Box`: The view box is an axis aligned box that defines where the picture will be taken, with both min and max z dimensions indicating the single z elevation the slice is taken at.
* `dim::Int64`: The dimension is the number of pixels along the x and y axis to use, which determines the resolution of the picture.
"""
function plot_geometry_2D(geometry::Geometry, view::Box, dim::Int64)
Expand Down

0 comments on commit a95be03

Please sign in to comment.