SolveSpace Logo SOLVESPACE -- parametric 2d/3d CAD
Examples
Tutorials
Features
Download
Reference
Technology
Library
Forum
Contact
USER FORUM

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

System that solves in GUI doesn't seem to converge via library (by Sean)
I'm testing out python-solvespace [1] which binds SolveSpace's C++ classes to Python classes. I've solved some very simple systems using this interface, but for some reason a simple triangle system is not solved. I suspect that the problem is *not* the Python bindings, but rather with my understanding of what I need to do to constrain the system, since the error I get indicates that the system is not converging.

The problem I'm trying to solve is a simple 2D equilateral triangle, with three line segments (with coincident points at the vertices), two angle constraints and one distance constraint. Given that 2 out of 3 angles are constrained, and one side length, the system is I believe fully constrained (within its own local coordinate system, at least). In the SolveSpace GUI, this system is solvable, and the triangle is draggable as one rigid entity, but freely movable in the global coordinate space as expected due to the lack of a constraint on the position with respect to the origin. The same set of constraints defined via the library, however, gives me the error "SLVS_RESULT_DIDNT_CONVERGE". This is the case even when I set the points close to their final locations as calculated via the SolveSpace GUI.

What is interesting is that if I instead constrain two side lengths and one angle, the system solves.

Does anyone have an idea what I'm missing here?

An image of the SolveSpace GUI with the successfully solved problem is in [2]. The python-solvespace code that is failing is attached. (Note that you need to have downloaded and compiled python-solvespace [1] to make this work.)

[1] https://github.com/KmolYuan/python-solvespace/
[2] https://postimg.cc/image/jpopxaohj/
Wed Sep 12 2018, 03:11:45, download attachment triangle.py
(no subject) (by Henrik)
Hi Sean,

I experimented with your code and I managed to make it work by adding 90 degrees to the angles. I haven't grok'd the solution completely, but my guess is that it has to do with line orientations.

> Constraint.distance(100, Workplane1, Point3, Point4)
> Constraint.vertical(Workplane1, Line2)
> Constraint.angle(Workplane1, 90+60, Line2, Line1)
> Constraint.angle(Workplane1, 60, Line3, Line1)
Wed Sep 26 2018, 16:00:29
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):
© 2008-2022 SolveSpace contributors. Most recent update June 2 2022.