Hi everybody again ,
I have a doubt that may be anybody can help me:
When I have two elements connected between them vertex to vertex or vertex to any point of the another line , the distance must be = 0 , but I see that if I use the equation of the line like using the method ComputeMinimumDistance of the BsplineCurve , it returns me values more bigger than 0 , like exponent -4 or similars in any cases.
Usually I obtain , when two elements are connect , values like Exp -12 or similar , but in any cases like I say of -4 aprox.
Anybody knows if there is any solution to it , like configure the work units or similar ???
If more information is needed or I have no explained me correctly , please let me know and I will explain better.
Thanks for your help in advanced.
Regards !!
Hi Xavi García,
Jon wrote the most important facts I think, so just a few more comments:
To understand what floating point number are, how they are implemented and what risks and threats exist there is mandatory knowledge for any CAD computation in my opinion. No deep detail experience is rewquired, just to understand basics and accept the most imporant things (like "test numbers equality is nonse ;-) and to know best practices. Wiki page mentioned by Jon is good start, but you can find plenty of articles and blogs on Internet (e.g. this one).
Unknown said:When I have two elements connected between them vertex to vertex or vertex to any point of the another line , the distance must be = 0
No, no and once more no ;-) ... well, in theory on paper the distance is zero, but the core question is how it's implemented in a particular software plus how it's maintained (or crippled) by API. And because no floating point number is exact, is e.g. 1E-10 still valid value or it's zero? If your master units are meters, if working in GIS and cadastre, anything under 1 mm is "zero" because it's below precision how data are captured. So 1E-4 (0.1 mm) can be always evaluated as 0 ... but it's not how simple API works.
Unknown said:like configure the work units or similar
From general perspective, if any code depends on units configuration, it's bad and fragile code.
If you work with coordinates comming from differenct source (e.g. two elements), you should not use "simple math methods" like Point2dEqual, but Point2dEqualTolerance method, because it allows to define what is "below reasonable precision". Or you can implement own methods.
BTW It can be valuable to check some API or solution where precision and difference between math and implementation is important. I am talking about topology and GIS libraries, because any topology is always calculated with "what is enough precision" in mind and it's reflected in API also.
Unknown said: ComputeMinimumDistance of the BsplineCurve
As Jon wrote, BSpline is calculated element and it cannot be treated in the same way as e.g. line or line string.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Unknown said: that a distance of 0.1mm must be considered 0 for microstation ???
Not for MicroStation. MicroStation is not involved in such evaluation! MicroStation can be treated as "element storage" and it's defined that element coordinates (like in other CAD systems) are stored as floating decimal point numbers accordingly to IEEE standard. It's completely your responsibility to define what precision is critical for you (but it cannot be better than precision ensured by the storage itself). Every tool in MicroStation does the same: It works based on the precision specification ... e.g. element placemetn is not critical, but 3D modeling using Parasolid require some extra precision settings.
Unknown said: I supose that a value of a exponent -10 or -12 is considered like a 0 , but a -4
Again, it's you responsibility to research precision condition. Don't suppose, do serious math evaluation: What are your coordinates (in floating point math numbers close to zero have higher precision than big values numbers), what is required precision, with what precision you API works...
Unknown said: I must understand that I will not obtain a better precision of the connection
What is better precision? It sounds to me like magic things or nonsense form math point of view:
At the end, to work with B-splines required pretty good konwledge of B-splines math itself and also at least basics of precision concept in path extended by floating point implementation issues knowledge (and VBA limitations knowledge in this case also). And maybe it's the reson why so many software (GIS / topology / analysis, modeling and visualization etc.) work with linear geometry only.
Regards,
Rod WingSenior Systems Analyst
Unknown said:I wrote a VBA tip a few years ago on one way to handle it
Good tip!
MicroStation VBA has functions that do something similar for the UDTs. For example...
Regards, Jon Summers LA Solutions
Unknown said: RodWing I wrote a VBA tip a few years ago on one way to handle it Good tip! MicroStation VBA has functions that do something similar for the UDTs. For example... Point2dEqualTolerance (p1, p2, tolerance) Point3dEqualTolerance (p1, p2, tolerance) Vector3dEqualTolerance (v1, v2, tolerance) BsplineCurve.ComputeMinimumDistance (ClosestPoint, ClosestParameter, FromPoint, Rotation [, Tolerance]) Range3dEqualTolerance (Range0, Range1, Tolerance) IntersectRay3d (IntersectionPoint, Parameters, Ray [, Tolerance])
RodWing I wrote a VBA tip a few years ago on one way to handle it
Thank you.
Unfortunately the AutoCAD and Civil 3D API's lack a lot of those types of functions which means I have to develop my own.
To help make modules more portable between AutoCAD and MicroStation I will use my own utility functions in MicroStation applications even if there is something comparable available in the MicroStation API.
I wrote a tip on that too! :)
http://envisioncad.com/tips/create-portable-functions/
Thank you very much , I think that I can use the function you have posted "IsPointOnLine" to determinate if a Point is connected to a line , but if the precision of the distance between point and line is the precision of the value of the variable Zero I'm with the same problem ...
I'll try with it !! Thanks again for your help Jon , Jan and Rodwing !!!
Unknown said:If the precision of the distance between point and line is the precision of the value of the variable Zero I'm with the same problem ...
ZERO is defined as a constant value in Rod's VBA project. If you don't like the value he's chosen, you can define a different value.
Unknown said:I suppose that the value of constant zero is a value defined to determinate the minimum value of zero ... and in my macro If I define more small value of zero I will no detect elements conected ...
Welcome to computer programming! If this stuff were easy, then anybody could do it 8-)
Unknown said: Welcome to computer programming! If this stuff were easy, then anybody could do it 8-)
Code... We're the good guys now.