Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
does anyone has a function to add a vector to a list of points?
Solved! Go to Solution.
does anyone has a function to add a vector to a list of points?
Solved! Go to Solution.
Presuming your points list is in the format '((x1 y1 z1)(x2 y2 z2) etc.) and we call it PNTS, and we have one point as in (setq P '(10 20 0.0), then...
(setq PNTS (append PNTS (list P)))
Although the use of cons can be much faster, as in
(setq PNTS (reverse (cons p (reverse PNTS))))
John F. Uhden
@diegolopezsilanes wrote:
does anyone has a function to add a vector to a list of points?
You don't say whether the order of the resulting list matters, i.e. where the added one ends up in relation to what's already in the list. If it doesn't, just this will do:
(cons newpoint pointlist)
But I am a little curious about the terms "vector" and "points." In AutoCAD, vectors are expressed in the same way as points, but do you mean something different by it? Or do you, perhaps, mean you want to add a vector [such as an offset] to each point in an existing list of points? If that's what you need, this will do it:
(mapcar '(lambda (x) (mapcar '+ x YourVector)) YourPointList)
sorry, I was trying to sum the vector to the list of 2d points
@diegolopezsilanes wrote:
sorry, I was trying to sum the vector to the list of 2d points
Is the vector also 2D? If so, my edit-added suggestion should do. If it's 3D, and you want the Z coordinate of the vector added to make the 2D points 3D, a little more would need to be done, but it's possible.