Gargaj wrote a tutorial for newbies who want to code demos. It shows how to make a simple demo in less than 400 lines of C++ code. Link: https://gargaj.github.io/demos-for-dummies/
When you have a point cloud and want to obtain the shape, you can use the convex hull or the alpha shape algorithm. In the computational geometry library I am using in my projects, CGAL, these algorithms are built-in, but they have a disadvantage: the points are not output in the correct order. I first tried to solve this problem by implementing a convex hull algorithm myself that outputs the points in the correct order, but this did not always help since it ignored concave corners. Therefore I wrote my own algorithm to replace it. My algorithm divides the rectangular area of the given cluster into four triangles and computes the points belonging to the outer border of each triangle. Thus it also includes concave corners. Imagine this to be the rectangle: -------- |\ /| | \ A/ | | C\/ | | /\D | | /B \ | |/ \| -------- If it is a square, we can assume that its sides have a length of 2a. The coordinates of the mid point are always (0, 0). Th...
Recently I had to serialize a map in JavaScript. On the Internet I found code similar to this: /* json-map.js */ export const replacer = (key, value) => { if(value instanceof Map) { return { dataType: 'Map', value: Array.from(value.entries()), }; } else { return value; } } export const reviver = (key, value) => { if(typeof value === 'object' && value !== null) { if (value.dataType === 'Map') { return new Map(value.value); } } return value; } Now I had the problem that this works for maps of arrays, but not for maps of maps. I pondered over it for a while and then came up with a recursive solution that does not only work for maps of maps, but also for maps of maps of maps, maps of maps of maps of maps, and so on: /* json-map.js */ export const replacer = (key, value) => { if(value inst...
Comments
Post a Comment