Search code examples
algorithmdrawingverticescadparameterization

Efficient method for parameterizing distances between points in a 2D


We have been developing a small simple "CAD" solution that allow us to parameterize the width and length of some specific, simple shapes.

For instance consider the following set of vertices forming a triangle. Where any 2 points form a line. So changing distances between point is changing width of the line.

Triangle

We have discussing rigorously about how to approach this problem.

Things that we have discussed are:

  1. Maintain a list of equations of all the relationship between all the vertices. Say we have point A, B, C. Let W be some user-defined parameter. The constraint equation for this shape would beBx = Ax + W, By = Ay, and Cx = Bx and so on.

The complexity is enormous but it works.

  1. Maybe model each vertex as a node in a graph...?

What is the proper approached widely used in this field?


Solution

  • I think you are trying to implement a simplified geometric constraint solver. Basically, the points location are determined by solving a set of nonlinear equation (i.e., constraints) with some boundary conditions (i.e., some points location are already known). If this is the case, it is not easy to do even when the only geometries involved are 2d points and the only constraints involved are distances between points. Anyway, in this field, implementing a numeric solver via minimization is a typical approach. A more general solution will involve a mix of numeric solver and algebraic solver.

    Here is a link that contains a lot of information about constraint solver, including geometric constraint solver. Hopefully, you can find something useful here.