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

Function appendArc

lib/offset-polygon.js:69–90  ·  view source on GitHub ↗
(arcSegments, vertices, center, radius, startVertex, endVertex, isPaddingBoundary)

Source from the content-addressed store, hash-verified

67 };
68}
69function appendArc(arcSegments, vertices, center, radius, startVertex, endVertex, isPaddingBoundary) {
70 var startAngle = Math.atan2(startVertex.y - center.y, startVertex.x - center.x);
71 var endAngle = Math.atan2(endVertex.y - center.y, endVertex.x - center.x);
72 if (startAngle < 0) {
73 startAngle += TWO_PI;
74 }
75 if (endAngle < 0) {
76 endAngle += TWO_PI;
77 }
78 const angle = startAngle > endAngle ? startAngle - endAngle : startAngle + TWO_PI - endAngle;
79 const angleStep = (isPaddingBoundary ? -angle : TWO_PI - angle) / arcSegments;
80 vertices.push(startVertex);
81 for (let i = 1; i < arcSegments; ++i) {
82 const angle2 = startAngle + angleStep * i;
83 const vertex = {
84 x: center.x + Math.cos(angle2) * radius,
85 y: center.y + Math.sin(angle2) * radius
86 };
87 vertices.push(vertex);
88 }
89 vertices.push(endVertex);
90}
91function createOffsetEdge(edge, dx, dy) {
92 return {
93 vertex1: {

Callers 2

createMarginPolygonFunction · 0.70
createPaddingPolygonFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected