PDA

View Full Version : adding values to points in alisp

joker
2nd Oct 2004, 07:13 pm
Could someone tell me how to add values to points. I want to make a square using a user input first point. How would I create a second point by adding values to the first point?

hendie
2nd Oct 2004, 10:16 pm
after you have the first point, you then extract the X & Y values (and possibly Z), then you add the figures you need to concoct the next point. which figures all depend upon which way you want to draw the rectangle from the first point.
I think you need to provide a little bit more info here

David Bethel
2nd Oct 2004, 10:24 pm
There are several ways to approach this:

(setq p1 '(2 3 0))

maybe:

(setq p2 (mapcar '+ p1 '(2 2 0)))

or:

(setq ap (lambda (p s)
(list (+ (car p) s)

(setq p2 (ap p1 2))

-David

CAB
13th Oct 2004, 12:31 am
Here are some more examples.
Lets start at point 2,2 and go around a square.

&#40;setq x 2
y 2
&#41;

&#40;setq p1 &#40;list x y&#41;
p2 &#40;list x &#40;+ y 5&#41;&#41;
p3 &#40;list &#40;+ x 5&#41; &#40;+ y 5&#41;&#41;
p4 &#40;list &#40;+ x 5&#41; y&#41;
&#41;

&#40;command "._pline" p1 p2 p3 p4 p1 ""&#41;
Lets go from p3 to 10,10
We need to add 3 to x & y

&#40;setq p5 &#40;list &#40;+ &#40;car p3&#41; 3&#41;&#40;+ &#40;cadr p3&#41; 3&#41;&#41;&#41;

Dommy2Hotty
13th Oct 2004, 03:53 pm
There's always "getcorner"