### Calculating Points - Polar

#### The Polar function is defined in the AutoCAD Customization manual as follows :

POLAR : Returns the UCS 3D point at a specified angle and
distance from a point.

(polar pt ang dist)

This, I believe, is one of the most useful functions in the AutoCAD stable.
In a nutshell, you feed it a point, tell it the angle and distance from that point that you want to be, and it will return the second point.
Can you imagine having to do that using car, cadr, etc.
First you would have to break the list down into each separate component, do all the calculations on each individual item, and then re-construct the list.
What a pain!!

Following is an example of how to use POLAR to construct a simple square
or rectangle from values input by the user :

```(defun DTR (a)					;degrees to radians function
(* PI (/ a 180.0))
);defun
;=========================================
(defun C:BOX1 (/ IP P1 P2 P3 LENGTH HEIGHT	;define function and declare
OLDSNAP OLDBLIP OLDLIGHT)	;variables as local

(setq OLDSNAP (getvar "OSMODE")			;store system variables
OLDBLIP (getvar "BLIPMODE")
OLDLIGHT (getvar "HIGHLIGHT")
);setq
;=========================================
(setvar "CMDECHO" 0)				;change system variables
(setvar "BLIPMODE" 0)
(setq IP (getpoint "\nInsertion Point: "))	;get insertion point
(setvar "OSMODE" 0)				;switch off snap
(setq LENGTH (getreal "\nEnter Length: ")	;get length of box
HEIGHT (getreal "\nEnter Height: ")	;get height of box
);setq
;=========================================
(setq P1 (polar IP (DTR 0.0) LENGTH)		;calculate first corner
P2 (polar P1 (DTR 90.0) HEIGHT)		;calculate second corner
P3 (polar P2 (DTR 180.0) LENGTH)		;calculate third corner
);setq
;=========================================
(command "PLINE" IP "W" "" ""
P1 P2 P3 "C"
);command					;draw the box
;=========================================
(prompt "\nRotation Angle: ")			;prompt the user for rotation
(command "ROTATE" "LAST" "" IP pause)		;rotate the box
;=========================================
(setvar "OSMODE" OLDSNAP)			;reset system variables
(setvar "BLIPMODE" OLDBLIP)
(setvar "HIGHLIGHT" OLDLIGHT)
(princ)						;exit quietly
);defun```

To save you typing here's the source code : Box1 Lisp (1 Kb)

As you can see, we first need to write a function to convert radians to degrees. This is because when we deal with angles in AutoLISP they must be in Radians.