Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Unit Test for the distort function #460

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Bersaelor
Copy link

See more about this issue in #459 .

For testing one can copy the following into the playground:

var makerjs = require('makerjs');

function Curve(distort, xScale, yScale) {

	var models = {"p_1":{"models":{"Curve_1":{"type":"BezierCurve","seed":{"type":"bezier-seed","origin":[49.19340000912696,-23.76643519775553],"controls":[[47.54589150912696,-25.69649809775553],[45.552802009126964,-27.30229669775553]],"end":[43.31640000912696,-28.50143519775553]},"accuracy":0.07590843534674546,"paths":{"arc_0":{"type":"arc","origin":[33.67472055622203,-10.519634308631232],"radius":20.403606194938142,"startAngle":298.199807985429,"endAngle":319.5158087684108,"bezierData":{"startT":0,"endT":1}}},"origin":[0,0]}},"origin":[0,0]},"p_2":{"models":{"Curve_1":{"type":"BezierCurve","seed":{"type":"bezier-seed","origin":[43.31640000912695,-28.501435197755505],"controls":[[38.86204880912695,-30.889806897755506],[33.76550680912695,-31.805471597755503]],"end":[28.75835610912695,-31.116990397755504]},"accuracy":0.1503768023646056,"paths":{"arc_0":{"type":"arc","origin":[32.015786530778335,-7.425626328142378],"radius":23.914296654835947,"startAngle":270.0002010368226,"endAngle":298.1997126557931,"bezierData":{"startT":0,"endT":0.7834851}},"arc_1":{"type":"arc","origin":[32.01587116747963,-7.430719116331623],"radius":23.90920386009164,"startAngle":266.59658772087886,"endAngle":269.99999825709114,"bezierData":{"startT":0.7834851,"endT":0.877811}},"arc_2":{"type":"arc","origin":[32.016413171354486,-7.422937174440527],"radius":23.917004325217437,"startAngle":262.17062743761306,"endAngle":266.59639830838796,"bezierData":{"startT":0.877811,"endT":1}}},"origin":[0,0]},"Curve_2":{"type":"BezierCurve","seed":{"type":"bezier-seed","origin":[28.75835610912695,-31.116990397755504],"controls":[[23.751205409126946,-30.428509197755503],[19.09093420912695,-28.171286697755505]],"end":[15.44650000912695,-24.669335197755505]},"accuracy":0.15037680217373628,"paths":{"arc_0":{"type":"arc","origin":[32.015885214648,-7.425797209967456],"radius":23.914098990645908,"startAngle":226.14219619655233,"endAngle":262.1709471254455,"bezierData":{"startT":0,"endT":1}}},"origin":[0,0]}},"origin":[0,0]},"p_3":{"models":{"Curve_1":{"type":"BezierCurve","seed":{"type":"bezier-seed","origin":[15.446500009127085,-24.66933519775545],"controls":[[11.831097509127083,-20.791131597755452],[9.265507009127091,-16.05423049775545]],"end":[7.992700009127091,-10.907235197755451]},"accuracy":0.15820534172941836,"paths":{"arc_0":{"type":"arc","origin":[38.2298715843712,-3.429847071353315],"radius":31.147999553859297,"startAngle":193.89008039829696,"endAngle":222.9914578935746,"bezierData":{"startT":0,"endT":1}}},"origin":[0,0]}},"origin":[0,0]},"p_4":{"models":{"Curve_1":{"type":"BezierCurve","seed":{"type":"bezier-seed","origin":[16.30270000912701,-23.831135197755675],"controls":[[12.82781940912701,-20.019453797755673],[10.018650609127022,-15.650570997755672]],"end":[7.992700009127006,-10.907235197755675]},"accuracy":0.1543732242958933,"paths":{"arc_0":{"type":"arc","origin":[50.301433893291865,7.163465810814486],"radius":46.00629519323109,"startAngle":203.12806187572835,"endAngle":222.3535484582318,"bezierData":{"startT":0,"endT":1}}},"origin":[0,0]}},"origin":[0,0]},"p_5":{"models":{"Curve_1":{"type":"BezierCurve","seed":{"type":"bezier-seed","origin":[42.75040000912695,-27.44593519775557],"controls":[[38.52464510912695,-29.71173109775557],[33.69030420912695,-30.58229949775557]],"end":[28.939596209126954,-29.93298559775557]},"accuracy":0.14266247815269273,"paths":{"arc_0":{"type":"arc","origin":[32.01573131323138,-7.425576418841636],"radius":22.71668720670064,"startAngle":270.0002092356444,"endAngle":298.19965880971256,"bezierData":{"startT":0,"endT":0.7844887}},"arc_1":{"type":"arc","origin":[32.015814774636404,-7.4303683107135825],"radius":22.711895111528666,"startAngle":266.5876290269404,"endAngle":269.9999987299335,"bezierData":{"startT":0.7844887,"endT":0.8791814}},"arc_2":{"type":"arc","origin":[32.01633294214731,-7.422931796790259],"radius":22.71934931206007,"startAngle":262.2168829757096,"endAngle":266.58744086010756,"bezierData":{"startT":0.8791814,"endT":1}}},"origin":[0,0]},"Curve_2":{"type":"BezierCurve","seed":{"type":"bezier-seed","origin":[28.939596209126954,-29.93298559775557],"controls":[[24.18888810912695,-29.28367159775557],[19.765462509126948,-27.147776797755572]],"end":[16.30270000912695,-23.83113519775557]},"accuracy":0.14266247891400313,"paths":{"arc_0":{"type":"arc","origin":[32.01582642274163,-7.425736889849418],"radius":22.716501419160014,"startAngle":226.23474280731844,"endAngle":262.2171906281835,"bezierData":{"startT":0,"endT":1}}},"origin":[0,0]}},"origin":[0,0]},"p_6":{"models":{"Curve_1":{"type":"BezierCurve","seed":{"type":"bezier-seed","origin":[49.46580000912701,-21.451735197755667],"controls":[[47.73377880912701,-23.95356119775567],[45.43210080912701,-26.008050697755667]],"end":[42.750400009127006,-27.445935197755666]},"accuracy":0.09085994852574675,"paths":{"arc_0":{"type":"arc","origin":[33.674739706033876,-10.519538918025617],"radius":19.206001692035418,"startAngle":298.19949060405645,"endAngle":325.3050334634886,"bezierData":{"startT":0,"endT":1}}},"origin":[0,0]}},"origin":[0,0]},"p_7":{"models":{"Curve_1":{"type":"BezierCurve","seed":{"type":"bezier-seed","origin":[49.193400009127075,-23.76643519775547],"controls":[[49.06490120912708,-22.98460039775547],[49.15930860912708,-22.182379197755473]],"end":[49.46580000912708,-21.45173519775547]},"accuracy":0.02361418469417214,"paths":{"arc_0":{"type":"arc","origin":[53.35361902736453,-23.082653333089993],"radius":4.216038415165353,"startAngle":182.1997915841359,"endAngle":189.33379485323778,"bezierData":{"startT":0,"endT":0.221679}},"arc_1":{"type":"arc","origin":[53.35334392246139,-23.082673843422867],"radius":4.215762774729025,"startAngle":180.0000394116183,"endAngle":182.19965655170333,"bezierData":{"startT":0.221679,"endT":0.2902806}},"arc_2":{"type":"arc","origin":[53.35374210119602,-23.082660484148075],"radius":4.216160808402082,"startAngle":157.24278314562974,"endAngle":180.00022095459184,"bezierData":{"startT":0.2902806,"endT":1}}},"origin":[0,0]}},"origin":[0,0]}};
	var distorted = !distort ? {models: models} : makerjs.model.distort({models: models}, xScale, yScale, false, 0.05);

	this.models = distorted.models;
}

Curve.metaParameters = [
    { title: "distort", type: "bool", value: false },
    { title: "xScale", type: "range", min: 0, max: 2, step: 0.05, value: 1 },
    { title: "yScale", type: "range", min: 0, max: 2, step: 0.05, value: 1 }
];

module.exports = Curve;

@msftclas
Copy link

msftclas commented Mar 6, 2020

CLA assistant check
All CLA requirements met.

@Bersaelor
Copy link
Author

It's a little weird that it says All checks have passed, since the test is currently failing locally. Thats the point of the PR, to talk about why those tests are failing.

@danmarshall
Copy link
Contributor

I'll pull it locally and check on my Windows machine. The CI uses Linux. What machine do you have where the tests fail?

@Bersaelor
Copy link
Author

Bersaelor commented Mar 6, 2020

I'm on a Mac, but I tested it on linux too (as I run it on AWS).
But the All checks have passed thing looks like the only check it did was whether I signed the license, not whether there were any tests run?

@danmarshall
Copy link
Contributor

It fails on my machine. Also, this PR isn't running on the Travis CI, I'll need to look into why.

@danmarshall
Copy link
Contributor

It did run, and fail, on the Travis build:
https://travis-ci.org/microsoft/maker.js/builds/659200713

Not sure why it does not appear here. I'll try triggering another build...

@danmarshall
Copy link
Contributor

Strange Travis issue... At first I didn't even see my organizational repos in Travis. Found this issue:
https://travis-ci.community/t/repos-in-organizations-not-visible/5985/6
Cleared my cookies and now I can see them, and the build is connected again.
My personal user account is the link to the builds?!?

@Bersaelor
Copy link
Author

Bersaelor commented Mar 6, 2020

yeah, I guess it's the same for me https://travis-ci.org/ViacomInc/ViaSwiftUtils is also still on my personal travis dashboard since I set it up (but haven't been working for Viacom for a few years now).

I'll have a look into what distort does and how it works and whether I can make heads and tails of it tomorrow, maybe I can also find something.
But at least we have a test that reproduces the problem.

@Bersaelor
Copy link
Author

Bersaelor commented May 8, 2020

Hey @danmarshall , I hope you are doing ok in those troubling days.

Do you have an idea where I could start in the maker.js codebase, in order to make this test pass?

@danmarshall
Copy link
Contributor

Hi Konrad, hope you are doing well also.
Perhaps start looking at where the path is distorted:

https://github.com/microsoft/maker.js/blob/master/packages/maker.js/src/core/path.ts#L387

Then where the model is distorted:
https://github.com/microsoft/maker.js/blob/master/packages/maker.js/src/core/model.ts#L466

I am going to suspect it may be in a bezier ...

@danmarshall danmarshall closed this Feb 1, 2023
@danmarshall danmarshall reopened this Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants