Ian's answer was quite helpful (thanks a lot) but it's still not a complete solution since we don't know the value of "size" in resolutions[z] = size / Math.pow(2, z).
It did however put me on the right track. Here's how I figured out the resolutions to use in my QWC2 themesConfig.json file.
The themesConfig.json example on the QWC2 download site shows the resolutions for a WMTS that is in the same projection.
{
"type": "wmts",
"url": "https://wxs.ign.fr/pratique/geoportail/wmts",
"title": "IGN",
"name": "GEOGRAPHICALGRIDSYSTEMS.MAPS",
"format": "image/jpeg",
"style": "normal",
"originX": -20037508,
"originY": 20037508,
"projection": "EPSG:3857",
"resolutions": [
156543.03392804097,
78271.51696402048,
39135.75848201024,
19567.87924100512,
9783.93962050256,
4891.96981025128,
2445.98490512564,
1222.99245256282,
611.49622628141,
305.748113140705,
152.8740565703525,
76.43702828517625,
38.21851414258813,
19.109257071294063,
9.554628535647032,
4.777314267823516,
2.388657133911758,
1.194328566955879
],
"tileSize": [256, 256],
"requestEncoding": "KVP",
"tileMatrixSet": "PM",
"tileMatrixPrefix": "",
"thumbnail": "ign.png",
"attribution": "<a href=\"http://www.geoportail.fr/\" target=\"_blank\"><img src=\"https://api.ign.fr/geoportail/api/js/latest/theme/geoportal/img/logo_gp.gif\"></a>"
}
So I tested my wmts with these resolutions and it worked until I got to a certain zoom lever. I figured the reason was the example has 18 resolutions but my WMTS has 22 scale denominators.
Since things worked for the 18 resolutions I had, the solution was as simple as doing a reverse calculation. I took the first 3 resolutions from the sample and divided them by the first 3 scale denominators I got from GetCapabilities.
156543.03392804097 / 559082264.02871787548065185547 = 0.00028
78271.51696402048 / 279541132.01435887813568115234 = 0.00028
39135.75848201024 / 139770566.00717940926551818848 = 0.00028
So clearly 0.00028 is a constant, all I had to do was multiply the last 4 scale denominators from my GetCapabilities by 0.00028 to get the 4 resolutions I was missing which are
0.597164283
0.298582142
0.149291071
0.074645535
The resolutions section of themesConfig.json for my WMTS is as follows, it works perfectly.
"resolutions": [
156543.03392804097,
78271.51696402048,
39135.75848201024,
19567.87924100512,
9783.93962050256,
4891.96981025128,
2445.98490512564,
1222.99245256282,
611.49622628141,
305.748113140705,
152.8740565703525,
76.43702828517625,
38.21851414258813,
19.109257071294063,
9.554628535647032,
4.777314267823516,
2.388657133911758,
1.194328566955879,
0.597164283,
0.298582142,
0.149291071,
0.074645535
],