algorithmic modeling for Rhino
Hi all,
I would like from a line find precise coordinates in X and Y to implement this line.
Exemple: this line:
I looking a coordinate round in the "infinte" line:
In this example I cheated by first tracing the line with precise coordinates, but the goal would be to start from a Line Draws without coorodnées.
Thanks for all !
Tags:
Hello Remy,
If your lines are random, mathematically, I don't think this is possible.
Your line has a y=Ax+B equation.
If it is a random line, A and B will also be random numbers, which means you won't have silmutaneously x and y coordinates as integers unless you're really lucky.
The best you can do to have round coordinates is to find the closest line with round A and B parameters.
If it is a random line, A and B will also be random numbers, which means you won't have silmutaneously x and y coordinates as integers unless you're really lucky.
Yes I would like to play with that chance ...
Maybe with galapagos or VB script ...
I guess you could use galapagos to find points on the line with a round x coordinate and a y coordinate as close as possible to a round number (like 13.0000054).
With a high level of precision, you'll get the best approximated line.
For nikos : I tried the grid approach... but it can be a lot of points!!!
My level of precision it's 0.0001 !
For nikos : I tried the grid approach... but it can be a lot of points!!!
Yes it's a very low solution !
maybe you could create a grid of points with the precision you are after and check for points with 0 distance from the line (or as Friou says, very small distance from the line).
Yes it is pretty much what I had in mind.
The problem is the point defintion of the grid!
Or place?
Very thanks nikos, always there to help me !!!
If you move the coordinates such that point A is at the origin, then you may be able to find a decent fraction that at least gives you an approximation to within some accuracy of the slope. You'll need to convert your floating point coordinates into integers (just multiplying by some large power of ten and rounding should do it), then you need to simplify the fraction y/x. For this you'll need to find the greatest common divisor. But even then you're likely to just end up with some huge irreducible fraction.
Hopefully that'll give you somewhat smallish integer coordinates for the slope. But then you still need to project it onto integer coordinates to undo the moving.
All probleme is here.
As is to implement a lower tolerance millimeter would be enough.
Another problem: when X is interger, Y.
In the same idea as Friou I thinks its possible to solve with equations.
I attached a C# script which takes a "let's just look at a limited number of values and see which one is best" approach.
Inputs:
The algorithm works as follows:
This search only looks at two potential candidates per vertical ray, so it should run in O(N), not O(N^2).
Notes, this is designed to work only on lines that have no Z coordinates (2D only) and it won't work for lines that are exactly vertical.
Waouh!! Big work very Fast !!!
I'll watch it carefully thank you very much David !
It's possible to add one parameter of distance ?
For my line your line it's really to far !
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson.
Powered by