Slope-Intercept vs Raw End Points - Data Structure
In a graphics based programming, I’m starting to get the impression that it is better to store data in slope-intercept form rather than the raw start and end points.
Is my impression correct?
——
I originally posted the question above in r/math
Been thinking about it and yes there would be the special case where the slope is of defined.
My suspicion is that slope-intercept with start and end distances would be better because you are likely to need those values for intersection, collinearity (correct word?) and such testing functions. This way they would essentially be cached.
Thoughts?
Posted Jan 10, 2018, 11:32 PM UTC
13
What's that look like and can it convert to a line segment?
It’s essentially a bunch of random 2d line segments that I need to adjust to the nearest predetermined angle. Those angles come from a finite set of angles from 0 to 179.999_ . The source lines are simplified to fall into that range.
Collinear-overlapping lines are merged to eliminate redundancy.
The merge has a fuzz factor so that line segments that have similar angles and location are merged together.
After that all remaining lines are processed so that any end points within a fuzz distance are extended or trimmed to meet (while maintaining angle). I haven’t determine how to deal with more than two endpoints meeting. I may average them. I may not worry about it at all.
The final product writes out these adjusted line segments in angle point distance format.
My approach until recently was to just calculate angle, y (or x ) intercepts and lengths as needed while keeping the start and end points as the source of truth. But, it started to seem that if I based the truth on the intercept, angle and and distance from the intercept then some of the more difficult calcs/manipulations would become much easier.
I suppose that if I understood transformation matrices it would get even easier. But...I don’t.