Reimplementing constraint solver
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Reimplementing constraint solver
No, things are worse than that. I changed a to 0.1, and now it takes 32 subdivisions to arrive at error better than 1e-6
And in this case, the accuracy is improving extremely slowly as the number of subdivisions is increased, which is depressing. Something's wrong with my estimate.
And in this case, the accuracy is improving extremely slowly as the number of subdivisions is increased, which is depressing. Something's wrong with my estimate.
Re: Reimplementing constraint solver
I guess you are looking for a general method for other closed curves too, not only for an ellipse.DeepSOIC wrote: ↑Sat Mar 28, 2020 10:58 pm No, things are worse than that. I changed a to 0.1, and now it takes 32 subdivisions to arrive at error better than 1e-6
And in this case, the accuracy is improving extremely slowly as the number of subdivisions is increased, which is depressing. Something's wrong with my estimate.
Surely you know about the specific infinite series for the ellipse.
Something like "Infinite Series 2" of:
https://www.mathsisfun.com/geometry/ell ... meter.html
Then you do not have to subdivide...
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Reimplementing constraint solver
No, I didn't. Is there a version for an arc, not full ellipse?abdullah wrote: ↑Tue Mar 31, 2020 3:01 pm Surely you know about the specific infinite series for the ellipse.
Something like "Infinite Series 2" of:
https://www.mathsisfun.com/geometry/ell ... meter.html
Then you do not have to subdivide...
Re: Reimplementing constraint solver
None for an arc to my knowledge.
I found as advice, what you were doing:
http://mathforum.org/library/drmath/view/51945.html
I have started rewriting the solver interface of SketchObject to accomodate different solvers.
Re: Reimplementing constraint solver
I have a question regarding ParameterStore and HParameterStore.
I have been looking at your example code to create the "Sketcher.h" equivalent of FCS, which I called "FCSSketcher.h"
I appears to me that in FCSSketcher.h, I need an HParameterStore to... well ... to store the parameters of geometry and constraints.
I initially wrote something like:
Code: Select all
class SketcherExport FCSSketch : public SketchSolver
{
TYPESYSTEM_HEADER();
public:
FCSSketch();
...
private:
FCS::HParameterStore parameterStore;
};
This makes me think that maybe you thought it to be used in a different way... and that is the question. How did you intend to use it from c++.
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Reimplementing constraint solver
I guess you are getting a compile error that parameterStore must be initialized. Add : parameterStore(Py::None()) to the constructor, and then fill it in in constructor code by calling make method.
Or we can change it to support construction via new, I wanted to do that.
Or we can change it to support construction via new, I wanted to do that.
Re: Reimplementing constraint solver
More questions.DeepSOIC wrote: ...
So far, in FCSSketch, I have these data members:
Code: Select all
private:
// Solver
FCS::HParameterStore parameterStore;
// Interface classes
std::vector<GeoDef> Geoms;
std::vector<FCS::G2D::HParaPoint> Points;
};
Code: Select all
int FCSSketch::addPoint(const Part::GeomPoint &point, bool fixed)
{
//std::vector<double *> ¶ms = fixed ? FixParameters : Parameters;
// create our own copy
GeomPoint *p = static_cast<GeomPoint*>(point.clone());
// create the definition struct for that geom
GeoDef def;
def.geo = p;
def.type = GeoType::Point;
FCS::G2D::HParaPoint hp = new FCS::G2D::ParaPoint();
hp->
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Reimplementing constraint solver
The easiest is to call makeParameters method of ParaPoint.
Also, you can assign attributes x and y of parapoint directly, they are public. You can use setAttr, but it is for python, and thus has no compile-time type checking.
If you modify ParameterRefs x and y of parapoint after calling update, you should call update() again. There is a "touch" mechanism for automating the update calls to an extent, but it only really works one time. I have not bothered to set up a comprehensive mechanism, it seems to be too much of a challenge for too little gain.
Also, you can assign attributes x and y of parapoint directly, they are public. You can use setAttr, but it is for python, and thus has no compile-time type checking.
If you modify ParameterRefs x and y of parapoint after calling update, you should call update() again. There is a "touch" mechanism for automating the update calls to an extent, but it only really works one time. I have not bothered to set up a comprehensive mechanism, it seems to be too much of a challenge for too little gain.