0

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?

40pro
  • 1,283
  • 2
  • 15
  • 23
  • what exactly is the "problem"? May be it is just me but I do not get what you are asking at all. How does changing vertex distances change the line width??? Did you mean scaling polygon or offsetting outline instead? – Spektre Aug 18 '17 at 13:07
  • say if the distance of vertex (100,100) and (200,100) is parameterized by parameter W. if we want to increase W, we apply some algorithm to translate either (100,100) or (200,100) to a new location that will cause W to increase. ex. Translate (200,100) to (300,100) will increase W by 50%. Basically. Thats what i meant. – 40pro Aug 18 '17 at 17:44
  • moving line end-point along line direction is easy for example you got `A,B` and want to change the size so `B' = A + t*(B-A)` where `t` is your parameter if `t=1.0` then no change ... if `t=2.0` then the length is doubled ... if `t=0.5` then the length is halved ... – Spektre Aug 18 '17 at 20:42
  • yeah i guess thats the idea. I'm trying to validate that if it is actually viable for production or not because from my understanding thing could get messy when u have like 100 vertices. – 40pro Aug 19 '17 at 10:29
  • without proper problem description is hard to say ... if you want to preserve the shape then you need to change scale instead of point movement ... – Spektre Aug 19 '17 at 14:13

1 Answers1

1

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.

fang
  • 3,473
  • 1
  • 13
  • 19