USER FORUM

*(you are viewing a thread; or go back to
list of threads)*

**New tangent-arc-like feature request**

*(by Mike J. Bell)*

Hi! I love using the tangent-arc feature to smooth out sharp tabs on 2D drawings. I would like to have a similar feature for smoothing slots (to reduce 90 degree angle strain, for instance on acrylic). However, I'm not familiar with the constraint library code and I figured someone who was would be able to point me in the right direction very quickly.

I've attached a zip file with 5 models. The base file is angle.slvs, and it just has a simple weird quadrilateral used as an example throughout.

The second file is tangent.slvs. This was made by simply running "Tangent arc" on the upper left vertex of the base quadrilateral.

The third file is constructed tangent.slvs. I constructed, using basic SolveSpace elements and constraints, what I thought was the necessary and sufficient model (0 DOF) for how a tangent arc must be created.

The fourth file is new operation.slvs. This shows the new construction that I *want* to happen. It is very similar to the tangent arc, except that the upper left vertex is *on* the circle (so the other tangents are no longer perpendicular to the quadrilateral line segments; their angles are equal though).

The fifth file is result.slvs, which is what I would expect the final result of pressing Shift-B or whatever the hotkey would be (for dogBone?).

So I could probably find all the places to add code to make a new operation, I just don't know what I would put in modify.cpp to actually implement the operation (similar to GraphicsWindow::MakeTangentArc(void))

Anybody have good pointers? Thanks in advance...

I've attached a zip file with 5 models. The base file is angle.slvs, and it just has a simple weird quadrilateral used as an example throughout.

The second file is tangent.slvs. This was made by simply running "Tangent arc" on the upper left vertex of the base quadrilateral.

The third file is constructed tangent.slvs. I constructed, using basic SolveSpace elements and constraints, what I thought was the necessary and sufficient model (0 DOF) for how a tangent arc must be created.

The fourth file is new operation.slvs. This shows the new construction that I *want* to happen. It is very similar to the tangent arc, except that the upper left vertex is *on* the circle (so the other tangents are no longer perpendicular to the quadrilateral line segments; their angles are equal though).

The fifth file is result.slvs, which is what I would expect the final result of pressing Shift-B or whatever the hotkey would be (for dogBone?).

So I could probably find all the places to add code to make a new operation, I just don't know what I would put in modify.cpp to actually implement the operation (similar to GraphicsWindow::MakeTangentArc(void))

Anybody have good pointers? Thanks in advance...

**(no subject)**

*(by Jonathan Westhues)*

Have you reviewed MakeTangentArc()? It looks complicated, but that's mostly just because it rounds arbitrary curves as well as lines. It therefore has to solve numerically for the arc's endpoints. Once those have been calculated, the code to generate the desired entities and constraints should be pretty straightforward, and your "dogbone" feature would be analogous.

There shouldn't be any need to modify the constraint solver, if you specify the dogbone using only existing constraints (as you did in your examples). A new constraint would avoid the construction geometry that you're using now, and thus simplify the sketch. That would break backwards compatibility, though, and it doesn't seem too useful except in this specific context.

There shouldn't be any need to modify the constraint solver, if you specify the dogbone using only existing constraints (as you did in your examples). A new constraint would avoid the construction geometry that you're using now, and thus simplify the sketch. That would break backwards compatibility, though, and it doesn't seem too useful except in this specific context.

**Ahhhh...**

*(by Mike J. Bell)*

I wasn't reading very carefully; now I get it. I didn't recognize the estimation loop was due to the curve case, and just assumed that it was using some constraint code to handle the arc creation.

So the verbiage I was using in the OP was all wrong to describe my proposed solution...I don't really want a new constraint or to modify anything in the solver. I just need to follow the code to figure out how tangent-arc is modifying the existing sketch and adding components. The circle intersect/position calculation should be trivial with straight segments.

Anyways, now that you pointed that out, I think I'll take a crack at it! Have to set up my OSX dev environment for it first of course.

Thanks!

Mike

So the verbiage I was using in the OP was all wrong to describe my proposed solution...I don't really want a new constraint or to modify anything in the solver. I just need to follow the code to figure out how tangent-arc is modifying the existing sketch and adding components. The circle intersect/position calculation should be trivial with straight segments.

Anyways, now that you pointed that out, I think I'll take a crack at it! Have to set up my OSX dev environment for it first of course.

Thanks!

Mike

**(no subject)**

*(by Jonathan Westhues)*

That loop ensures that we call the constraint solver with an initial guess that satisfies our new constraints. If the solver were ideal, then this wouldn't be necessary; but for real, we'd otherwise risk non-convergence, or convergence to an undesired solution.

Let me know if you have any questions about creating the new entities and constraints. That corresponds pretty directly to the operations that you perform in the GUI, though.

Let me know if you have any questions about creating the new entities and constraints. That corresponds pretty directly to the operations that you perform in the GUI, though.

**Sort of stuck**

*(by Mike J. Bell)*

So I tried to translate the simple geometric calculations into code. It compiles and doesn't seem to run into any allocation or lifecycle type problems, but clearly the new entity is bogus (the radius ends up 0, lines end up with NaNs, etc.). I was wondering if you could look at it and see if you could tell where I went wrong?

I have only attached the modified source files...my clone was made on Dec 10th at 1737 EST. Most is just UI plumbing, and the real work is in modify.cpp. It has a new method called MakeDogboneArc() which started as a clone of MakeTangentArc(). (Side question: assuming I get this to work properly, what's the appropriate way for submitting a branch/patch for merge consideration?)

I commented modify.cpp:MakeDogboneArc() to explain (hopefully) what I was trying to do with each step. I also included a simple .slvs to illustrate (with comments) the geometric overall picture (points with labels, some known invariants, etc.).

Do you think you could spare a couple of minutes to take a look and see where I lost my way? I'd really appreciate it. Let me know if there's a better way to approach asking questions or working towards a solution (I'm not sure if this forum space is appropriate for such detailed implementation/developer topics).

Thanks!

Mike

I have only attached the modified source files...my clone was made on Dec 10th at 1737 EST. Most is just UI plumbing, and the real work is in modify.cpp. It has a new method called MakeDogboneArc() which started as a clone of MakeTangentArc(). (Side question: assuming I get this to work properly, what's the appropriate way for submitting a branch/patch for merge consideration?)

I commented modify.cpp:MakeDogboneArc() to explain (hopefully) what I was trying to do with each step. I also included a simple .slvs to illustrate (with comments) the geometric overall picture (points with labels, some known invariants, etc.).

Do you think you could spare a couple of minutes to take a look and see where I lost my way? I'd really appreciate it. Let me know if there's a better way to approach asking questions or working towards a solution (I'm not sure if this forum space is appropriate for such detailed implementation/developer topics).

Thanks!

Mike

**(no subject)**

*(by Jonathan Westhues)*

I'll review when I get a chance; but are you debugging graphically, like by plotting intermediate points with glxDrawEdges(), or adding them to SS.nakedEdges to be plotted that way upon paint? That's typically easier than looking at coordinates.

**Nevermind!**

*(by Mike J. Bell)*

I'm an idiot, I reversed my start/finish logic right at the beginning. Let me sew the rest up and see if it works...thanks for the tips.

**(no subject)**

*(by whitequark)*

We should really do something to the shortcut proliferation...

**no shortcut needed**

*(by Mike J. Bell)*

I can take the shortcut away, no problem. What's the best way to submit my changes for review? Should I fork on github and make a commit to the fork? Or make a patch and mail it? etc. etc. Thanks...

**(no subject)**

*(by whitequark)*

@Mike, please make a commit to your fork. I will review it and at some point include into my patch queue, which I regularly push upstream.

**Commit completed**

*(by Mike J. Bell)*

Thanks whitequark! Here's the URL:

https://github.com/ckimyt/solv...15bfc68f50f68fa501e445eb55d888

Like I said in my comments, the geometry is sound but the code is probably ugly; there are several similarities with tangent arc construction that could be factored out, and I'm sure there are better ways to handle the requests and entities than what I hacked (copied) in there.

https://github.com/ckimyt/solv...15bfc68f50f68fa501e445eb55d888

Like I said in my comments, the geometry is sound but the code is probably ugly; there are several similarities with tangent arc construction that could be factored out, and I'm sure there are better ways to handle the requests and entities than what I hacked (copied) in there.

**(no subject)**

*(by whitequark)*

Your code has an issue; the newly created parts aren't constrained to the original lines.

**Post a reply to this comment:**