Random shapes of haing equal area using Bezier curve - random

I am trying to generate random shapes of equal areas. I am following another post where random shapes are created https://stackoverflow.com/a/50751932/11078529
Is it possible to put a constraint like equal surface area while generating shaped using Bezier curve.

Related

How to find square shape from a list of points?

I'm trying to write a small drawing app where I want to be able to draw shapes by hand and the app will identify the kind of shape and redraw it using vector graphics.
Supposing that I have a list of 2D points that represent the following image:
What algorithms should I use in order to:
Determine that the shape is a square and not another shape or curve/arc;
Determine the edges of the square

3D mesh generation: How to choose up-axis when extruding 2D shape along 3D curve?

I have a 2D shape (a circle) that I want to extrude along a 3D curve to create a 3D tube mesh.
Currently the way I generate cross-sections along the curve (which form the basis of the resulting mesh) is to take every control point along the curve, create a 3D transform matrix for it, then multiply the 2D points of my circle by those curve-point matrices to determine their location in 3D space along the curve.
To create the matrix (from 3 vectors), I use the tangent on the curve as the up vector, world-up ([0,1,0]) as the forward vector, and the cross product of the up/forward vectors as the right vector. All three vectors are also orthogonalized during the process to create the final matrix.
The problem comes when my curve tangent is identical to the world-up axis. Ie, my tangent vector is [0,1,0] and the world-up is [0,1,0]....since the cross product of two parallel vectors is not explicit....the resulting extruded mesh has artifacts along those areas of the curve (pinching, twisting, etc).
I thought a potential solution would be to use the dot product of the curve tangent and the world-up as an interpolation value to shift my forward vector from world-up to world-right...in other words, as a curve tangent approaches [0,1,0], my forward vector approaches [1,0,0]...but that results in unwanted twisting along the final mesh as well.
How can I extrude my shape along a curve in a consistent manner that has no flipping/artifacts/twisting? I know it's possible since various off-the-shelf 3D applications can do it...I'm just not sure how.
One way I would approach this is to consider my tangent vector to the 3D curve as actually being a normal vector of the plane I am interested into.
Let's say, the tangent vector is
All you need now is two other vectors that are othoghonal to it, so let's.
Let's construct v like so:
(rotating the coordinates). Because v is the result of the cross product of u and something else, you know that v is orthogonal to u.
(This method will not work if u have equal x,y,z coordinates, in that case, construct the other vector by adding random numbers to at least two variables, rince&repeat).
Then you can simply construct w like before:
normalize and go.

What is the Pseudo-Hillbert curve equivalent for hexogonal and triangular tesselations?

Triangles, squares and hexagons can all be used to fill a surface (tessellation).
For now let's assume the surface has a limited number of tiles (triangles, squares or hexagons)
The goal is to define a line that touches each tile so that points that are close to each other or the line (1D) are also close to each other on the surface (2D).
The solution for a square based tesselation you have the (Pseudo)-Hillbert curve. Below is an example of a second order pseado-hillbert curve.
Explained in this fantastic video
I was wondering what the equivalent (if any) of the pseudo-hillbert curve for tesselations based on triangles or hexagons are. I am looking for a full tesselation so no holes as in a Sierpinsky Triangle.
I found this great resource
And for triangles using a Peano curve.

Averaging shapes (boundary points) of arbitrary objects

I have few images (contours) of an object. However, I would like to average these shapes and use the averaged shape of the object for further shape analysis.
Example:
In the above image, I have stacked the contour to illustrate my example.
I have implemented the first two steps of the algorithm below:
1) Find centroid of both these object shape
2) Align the centers
3) Interpolate the object shape
Since, I am not representing the shapes using some parametric/analytic equation, how can I get the interpolated object shape (i.e. third step)?
Thanks in advance
If you do not have a parametric form for your shape, you can:
For each shape, create a signed distance field that is positive inside the boundary and negative outside (or vice-versa). This can be based on (e.g.) a distance transform and is evaluated at every pixel.
Compute the average of the signed distance fields
Compute the interpolated shape from the zero-crossing of the averaged field
I think this paper describes a similar method (though probably more sophisticated): "Shape-based interpolation using a chamfer distance" http://rd.springer.com/chapter/10.1007/BFb0033762 , but I don't have journal access at my current location to check.

Filling the area inside of a irregular shaped polygon in opengl es

I have a set of points that outlines my polygon. The polygon can have many different shapes including convex shapes (imagine the shape of a crescent moon). I thought I could fill the inside of these shapes by using a triangle fan that started at the first point on the perimeter, but this fails badly on certain shapes.
How do people get this done? I wish there was a glPaintBucket function.
I believe you need to use the (intrinsically filled) triangle primitive after breaking up your polygon into triangles (start here to learn about polygon triangulation).

Resources