Message 1 of 5
Sort objects in order away from given point...

Not applicable
04-05-2006
10:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Have the user select a group of objects.
Have the user indicate a beginning point and angle through those objects.
Now I want to order those objects away from the beginning point along a line parallel to the user's indicated angle.
I can process all the xy from each of the objects, get the xy of the user's point and it's angle in radians. What I can't seem to do is come up with a calculation that provides me with a single number for each object which, when sorted (using vl-sort), are in order away from the user's point.
I've tried this calculation to create that single number:
(setq newxy (* (sqrt (+ (expt objx 2) (expt objy 2))) (- (cos (atan objy objx)) udir)))
...which essentially is trying to convert everything to radians, etc. What the single number ends up being is irrelevent except for the order sequence.
Some of my calculations work in one direction but when I reverse the direction, don't. Or I can get it to work going both ways as long as it's in the x dir but not in any other angle.
I think part of the issue is which quadrant the objects are in related to 0,0 but I'm lost as to how to allow for that. I once thought maybe I could simply subtract the user's point from the objx and objy but that didn't seem to work either.
Thoughts or suggestions?
Merle
Have the user indicate a beginning point and angle through those objects.
Now I want to order those objects away from the beginning point along a line parallel to the user's indicated angle.
I can process all the xy from each of the objects, get the xy of the user's point and it's angle in radians. What I can't seem to do is come up with a calculation that provides me with a single number for each object which, when sorted (using vl-sort), are in order away from the user's point.
I've tried this calculation to create that single number:
(setq newxy (* (sqrt (+ (expt objx 2) (expt objy 2))) (- (cos (atan objy objx)) udir)))
...which essentially is trying to convert everything to radians, etc. What the single number ends up being is irrelevent except for the order sequence.
Some of my calculations work in one direction but when I reverse the direction, don't. Or I can get it to work going both ways as long as it's in the x dir but not in any other angle.
I think part of the issue is which quadrant the objects are in related to 0,0 but I'm lost as to how to allow for that. I once thought maybe I could simply subtract the user's point from the objx and objy but that didn't seem to work either.
Thoughts or suggestions?
Merle