Solution to the Computational Geometry Engineer Challenge
Given a set of vertices connected by edges, provided in a JSON data structure, write an algorithm that finds all of the interior faces (polygons) of such a data structure. The output schema should be a simple JSON format.
project
│ README.md
| index.html (Web Page)
│
└───scripts
│ │ frontEnd.js (Front End)
│ │ index.js (Algorithm #1 Solution)
│ │ tests.js (Algorithm #1 Tests)
│ │ neighborFace.js (Algorithm #2)
│
└───images
└───styles
import ha-geometry-technical-challenge as gtc
//input
const inputJSON = {
"vertices": [[0,0], [2,0], [2,2], [0,2]],
"edges": [[0,1], [1,2], [0,2], [0,3], [2,3]]}
//output
const outputJSON = {
{"name":"Face 1","vertices":[[2,0],[0,0],[2,2]],"edges":[[1,0],[0,2],[2,1]]},
{"name":"Face 2","vertices":[[2,2],[0,0],[0,2]],"edges":[[2,0],[0,3],[3,2]]}
}
//returns output
gtc.textData(input)
Use the package manager npm to install file.
npm install ha-geometry-technical-challenge