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

Function appendArc

docs/src/offset-polygon.js:68–89  ·  view source on GitHub ↗
(arcSegments, vertices, center, radius, startVertex, endVertex, isPaddingBoundary)

Source from the content-addressed store, hash-verified

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

Callers 2

createMarginPolygonFunction · 0.70
createPaddingPolygonFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected