MCPcopy Create free account
hub / github.com/Stanko/offset-polygon / inwardEdgeNormal

Function inwardEdgeNormal

docs/src/offset-polygon.js:2–10  ·  view source on GitHub ↗
(vertex1, vertex2)

Source from the content-addressed store, hash-verified

1const TWO_PI = Math.PI * 2;
2function inwardEdgeNormal(vertex1, vertex2) {
3 const dx = vertex2.x - vertex1.x;
4 const dy = vertex2.y - vertex1.y;
5 const edgeLength = Math.sqrt(dx * dx + dy * dy);
6 return {
7 x: -dy / edgeLength,
8 y: dx / edgeLength
9 };
10}
11function outwardEdgeNormal(vertex1, vertex2) {
12 var n = inwardEdgeNormal(vertex1, vertex2);
13 return {

Callers 2

outwardEdgeNormalFunction · 0.70
createPolygonFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected