PDA

View Full Version : ...program these equations?



D2008
30th Jan 2008, 04:48 pm
Hi


I have a problem. I need to apply the following equations to a complete drawing in AutoCAD (2004):


X2 = a*X1*cos (b)+a*Y1*sin (b)+c
Y2 = -a*x1*sin (b)+a*Y1*cos (b)+d
where the variables are Variables:
a,b (rad), c and d

X1 and Y1 correspond to original coordinates of the plane and X2 and Y2 to the new coordinates of the plane.

It is possible to program these equations in Autolisp? :unsure:



Thanx




D2008

Alan Cullen
30th Jan 2008, 04:53 pm
yeah, it is possible to do that in lisp.

lpseifert
30th Jan 2008, 05:09 pm
Is the input for b decimal degrees or what? and what is sen?

D2008
30th Jan 2008, 05:28 pm
Is the input for b decimal degrees or what? and what is sen?


lpseifert
b expressed in radians
sen = sin "sine"

Thanx

D2008

lpseifert
30th Jan 2008, 05:56 pm
Better check the math


(defun c:j1 ()
(setq a (getreal "Enter variable a: ")
b (getreal "Enter variable b: ")
c (getreal "Enter variable c: ")
d (getreal "Enter variable d: ")
X1(getreal "Enter original X coordinate: ")
Y1(getreal "Enter original y coordinate: ")
X2 (+ (* (cos b) a X1) (* (sin b) a Y1) c)
Y2 (+ (* (sin b) (* -1.0 a) X1) (* (cos b) a Y1) d)
);setq
(alert
(strcat "\n X2= " (rtos X2 2 4)
"\n Y2= " (rtos y2 2 4)
);strcat
);alert
);defun

D2008
30th Jan 2008, 07:52 pm
lpseifert,

This code will be the basis to understand the programming in AutoLisp and to develop solutions to my problems. Thank you very much… :)

From the foothills of Los Andes!

D2008

lpseifert
30th Jan 2008, 07:57 pm
Here (http://www.afralisp.net/) is a good source for learning lisp.