https://codepen.io/ysraeljmm/pen/rrbrQJ
Function toVertex Perhaps the following function (it's JavaScript) could help you.
The first parameter is an element of type SVG, it can be a path, rect, circle, etc. The second parameter is the distance of segments. Returns an array as a javascript object, which is generally used in Phaser or matter js.
function toVertex(pathSVG, n){
let pathLength = pathSVG.getTotalLength();
let vtx = [];
var i = 0;
while(i < pathLength){
let arr = pathSVG.getPointAtLength(i);
vtx.push({x:arr.x, y:arr.y});
i+=n;
}
return vtx;
}