Members
algorithm :Enum.<String>
Variable that stores the current algorithm tha is being executed
Type:
- Enum.<String>
(constant) algorithms :String
Enumeration of the different algorithm types
Type:
- String
(constant) direction :String
Enumeration of the possible directions the algorithm can use when
generating the convex hull
Type:
- String
(constant) divideSteps :Integer
Enumeration of the possible state the divide and conquer algorithm can be in
Type:
- Integer
(constant) grahamSteps :Integer
Enumeration of the possible state the graham scan algorithm can be in
Type:
- Integer
(constant) jarvisSteps :Integer
Enumeration of the possible state the jarvis march algorithm can be in
Type:
- Integer
(constant) monotoneSteps :Integer
Enumeration of the possible state the monotone chain algorithm can be in
Type:
- Integer
- Source:
numPoints :Integer
Number of points to be bound by the generated convex hull
Type:
- Integer
pointRadius :Integer
Size of the points drawn on the canvas
Type:
- Integer
pointsDisplay :p5.Element
Pointer for the paragraph which shows the number of points in the DOM
Type:
- p5.Element
pointsSlider :p5.Element
Pointer for the number of points slider in the DOM
Type:
- p5.Element
selectAlgorithm :p5.Element
Pointer to select field that selects the executing algorithm
Type:
- p5.Element
selectAngularDirection :p5.Element
Pointer to select field that selects the direction that the Jarvis march
algorithm finds theconvex hull
Type:
- p5.Element
selectSplitMethod :p5.Element
Pointer to select field that selects the method that is used to split the
points when divide and conquer is running
Type:
- p5.Element
(constant) splitMethods :String
Enumeration of the different methods for splitting the points
Type:
- String
xBuffer :Integer
Variable that store how far away from the side edges new points can spawn
Type:
- Integer
yBuffer :Integer
Variable that store how far away from the top and bottom edges new points
can spawn
Type:
- Integer
Methods
algorithmSelectEvent()
Changes the algorithm depending on what the value of the selectAlgorithm
element is
angularSelectEvent()
Changes the direction the jarvis march algorithm selects new points for the
convex hull depending on the value of the selectAngularDirection element
calculateHull(hullIndex)
Calculates the internal hull for one of the subsections after division
Parameters:
Name | Type | Description |
---|---|---|
hullIndex |
Integer | Select which hull to calculate from 0 to 2 |
chunkArray(array, chunkSize)
Returns an array with arrays of the given size.
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array to split |
chunkSize |
Integer | Size of every group |
crossZ(a, b, o) → {Float}
Finds the z component of the cross product of three vectors
Parameters:
Name | Type | Description |
---|---|---|
a |
p5.Vector | |
b |
p5.Vector | |
o |
p5.Vector |
- Source:
Returns:
- Type
- Float
divideAndConquer()
The Divide & Conquer algorithm
draw()
p5.js draw function, is run every frame to create the desired animation
drawEdges(hullArray, colour)
Draws the edges of a convex hull with a given colour
Parameters:
Name | Type | Description |
---|---|---|
hullArray |
Array.<p5.Vector> | Array of points that amke up the verticies of the hull. |
colour |
Integer | Value of the hue of the given hull from 0 to 100 |
drawHull(hullArray, colour)
Draws a convex hull with a given colour
Parameters:
Name | Type | Description |
---|---|---|
hullArray |
Array.<p5.Vector> | Array of points that amke up the verticies of the hull. |
colour |
Integer | Value of the hue of the given hull from 0 to 100 |
fuse()
Combines the three internal hulls into the final convex hull for all points
grahamScan()
The graham scan algorithm
jarvisMarch()
Jarvis March algorithm function
monotoneChain()
The monotone chain algorithm
- Source:
reset()
Reset all algorithm variables to initial values
setup()
p5.js setup function, creates canvas.
splitSelectEvent()
Changes the method for splitting the points in divide and conquer depending
on the value of the selectSplitMethod element