points module and huge coordinates ... problems

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: points module and huge coordinates ... problems

Post by DeepSOIC »

bernd wrote: Wed Sep 19, 2018 6:43 pm How would you guys cut the first five diggits from the x and y numbers before open the file in FreeCAD points?
It depends. I would probably load the file into a spreadsheet program (excel for example) and subtract something.

In text editor, find-replace can at least cut quite a few digits off.

edit: if th4e file structure is easy, maybe you can parse it with python or numpy, and do the subtraction there.
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: points module and huge coordinates ... problems

Post by wmayer »

You can try this:

Code: Select all

import Points

p=Points.Points()
p.read("problem.asc")
c=p.BoundBox.Center

n=Points.Points()
pts=[i-c for i in p.Points]
n.addPoints(pts)
Points.show(n)
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: points module and huge coordinates ... problems

Post by bernd »

libre office calc is what I have been playing already, but I do not like it because I will have this problem again and again ...

great, thanks guys for all the ideas. I will dig into it once and come back.

bernd
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: points module and huge coordinates ... problems

Post by bernd »

werner, your code works great. Does it mean the problem is in coin, and the read does not make use of coin thus import and move works with huge coordinates too!
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: points module and huge coordinates ... problems

Post by wmayer »

bernd wrote: Thu Sep 20, 2018 4:55 pm werner, your code works great. Does it mean the problem is in coin, and the read does not make use of coin thus import and move works with huge coordinates too!
Yes the problem is in Coin (or maybe even in OpenGL) because when interacting with the 3d view internally a lot of matrix multiplications are performed and as pointed out by DeepSOIC due to the huge rounding errors the rendered scene starts to jump.

So, the trick is to move the points to get some sensible coordinates.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: points module and huge coordinates ... problems

Post by bernd »

Would the following be possibe?
- if one opens a pcl with huge coordinates FreeCAD warns the user and asks him if he would like to move the pcl to the coordinate orgin or by a user given vector.
- if yes, I would make an issue as Feature request on mantis and link to this topic.

bernd
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: points module and huge coordinates ... problems

Post by wmayer »

Yes.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: points module and huge coordinates ... problems

Post by bernd »

User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: points module and huge coordinates ... problems

Post by Kunda1 »

Issue migrated to Github in issue #5808
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply