How to use the makerjs.solvers function in makerjs

To help you get started, weā€™ve selected a few makerjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / maker.js / demos / js / makerjs-heart.js View on Github external
function Heart(r, a2) {

    var a = a2 / 2;

    var a_radians = makerjs.angle.toRadians(a);

    var x = Math.cos(a_radians) * r;
    var y = Math.sin(a_radians) * r;

    var z = makerjs.solvers.solveTriangleASA(90, 2 * r, 90 - a);

    this.paths = {
        arc1: new makerjs.paths.Arc([x , 0], r, -a, 180 - a),
        line1: new makerjs.paths.Line([x * 2, -y], [0, -z + y])
    };

    this.paths.arc2 = makerjs.path.mirror(this.paths.arc1, true, false);
    this.paths.line2 = makerjs.path.mirror(this.paths.line1, true, false);
}
github microsoft / maker.js / demos / card.js View on Github external
function bend(r, bendTop, x, trimTo, outer) {

        outer = outer || 0;

        var hguide = new paths.Line([0, bendTop - r], [100, bendTop - r]);
        var vguide = path.rotate(new paths.Line([x, 0], [x, 100]), -speed, [x, 0]);
        var intersectionPoint = path.intersection(hguide, vguide).intersectionPoints[0];
        var center = point.subtract(intersectionPoint, [makerjs.solvers.solveTriangleASA(90, r, speed), 0]);

        var arc = new paths.Arc(center, r + outer, - speed, 90 + drop);

        var Horizontal = path.rotate(
                new paths.Line([-10, arc.origin[1] + r + outer], point.add(arc.origin, [0, r + outer])),
                drop,
                arc.origin
            );
        
        if (!outer) {
            trimLine(Horizontal, 'origin', trimTo);
        }

        var arcPoints = point.fromArc(arc);

        var Vertical = new paths.Line([x + makerjs.solvers.solveTriangleASA(90, outer, speed), 0], arcPoints[0]);
github microsoft / maker.js / demos / card.js View on Github external
}

    function leg(legTop, xOffset, trimTo) {

        this.models = {
            b1: new bend(ir, outline + legTop - serifHeight, speedOutline + xOffset, trimTo),
            b2: new bend(or, outline + legTop, speedOutline + columnWidth + xOffset, trimTo),
            b3: new bend(or, outline + legTop, speedOutline + columnWidth + xOffset, trimTo, outline)
        };

        this.paths = {
            legBottom: new paths.Line(this.models.b1.paths.Vertical.origin, this.models.b2.paths.Vertical.origin)
        };
    }

    var speedOutline = makerjs.solvers.solveTriangleASA(90, outline, speed);

    var bottomGuide = new paths.Line([0, outline], [100, outline]);

    var earline = path.rotate(new paths.Line([-ear, 0], [-ear, 100]), -speed, [-ear, 0]);

    var leg1 = new leg(mHeight, 0, earline);
    var leg2 = new leg(mHeight - step, columnWidth + spacing, leg1.models.b2.paths.Vertical);
    var leg3 = new leg(mHeight - 2 * step, 2 * (columnWidth + spacing), leg2.models.b2.paths.Vertical);

    var outBottom = new paths.Line([0, 0], leg3.models.b3.paths.Vertical.origin);

    var earPivot = leg1.models.b1.paths.Horizontal.origin;
    var earH = path.rotate(new paths.Line(point.subtract(earPivot, [100, outline]), point.subtract(earPivot, [-100, outline])), drop, earPivot);
    var outHome = trimLine(path.rotate(new paths.Line([0, 0], [0, 100]), -speed, [0, 0]), 'end', earH);
    var earOutline = trimLine(path.rotate(new paths.Line([-ear - speedOutline, 0], [-ear - speedOutline, 100]), -speed, [-ear - speedOutline, 0]), 'origin', earH);

makerjs

Maker.js, a Microsoft Garage project, is a JavaScript library for creating and sharing modular line drawings for CNC and laser cutters.

Apache-2.0
Latest version published 1 year ago

Package Health Score

67 / 100
Full package analysis