Advanced numeric functions in AutoLISP play a pivotal role in elevating your programming skills to the next level. These functions are not just mathematical tools; they are the key to unlocking the full potential of CAD designs, allowing for more intricate and precise manipulations. As we journey through today’s lesson, you’ll discover the depth and breadth of these functions and how they intertwine with realworld design challenges.
Whether it’s manipulating angles with trigonometric operations or diving into abstract mathematical paradigms, these tools will empower you to craft solutions that are both efficient and innovative. So, gear up and get ready to delve into the fascinating realm of advanced number manipulation in AutoLISP!
Learning OutcomesBy the end of this lesson, students will be able to:

angle
Definition: Returns the angle (in radians) between two points.
Syntax:
(angle point1 point2) 
Example 1:
(setq pt1 ‘(0 0)) (setq pt2 ‘(1 1)) (angle pt1 pt2) ; This will return a value approximating 0.785, which is 45° in radians. 
In this example, we’re finding the angle between the origin (0,0) and the point (1,1). The returned value is in radians.
Example 2:
(setq ptA ‘(2 2)) (setq ptB ‘(3 5)) (angle ptA ptB) ; This will return a value based on the angle between these two points in the Cartesian plane. 
Here, we determine the angle between two distinct points, (2,2) and (3,5).
cos
Definition: Returns the cosine of an angle (angle is in radians).
Syntax:
(cos angle) 
Example 1:
(cos 0) ; This will return 1. 
The cosine of 0 radians (or 0°) is 1.
Example 2:
(cos 1.5708) ; This will return a value close to 0. 
Here, we’re finding the cosine of approximately π/2 radians, which is close to 0.
sin
Definition: Returns the sine of an angle (angle is in radians).
Syntax:
(sin angle) 
Example 1:
(sin 0) ; This will return 0. 
The sine of 0 radians (or 0°) is 0.
Example 2:
(sin 1.5708) ; This will return a value close to 1. 
This gives us the sine of approximately π/2 radians, which is close to 1.
atan
Definition: Returns the arctangent of a quotient of its arguments.
Syntax:
(atan y x) 
Example 1:
(atan 1 1) ; This will return a value approximating 0.785, which is 45° in radians. 
Here, the arctangent of the quotient of 1/1 is found, which is 45° in radians.
Example 2:
(atan 2 1) ; This will return a value based on the arctangent of 2/1. 
This calculates the arctangent of the quotient of 2/1.
exp
Definition: Returns the exponential value of a number.
Syntax:
(exp number) 
Example 1:
(exp 0) ; This will return 1. 
The exponential function of 0 is 1.
Example 2:
(exp 1) ; This will return a value close to 2.71828, which is the base of the natural logarithm. 
The exponential function of 1 gives the base of the natural logarithm.
log
Definition: Returns the natural logarithm of a number.
Syntax:
(log number) 
Example 1:
(log 1) ; This will return 0. 
The natural logarithm of 1 is 0.
Example 2:
(log 2.71828) ; This will return a value close to 1. 
Here, we’re finding the natural logarithm of approximately the base of the natural logarithm.
sqrt
Definition: Returns the square root of a number.
Syntax:
(sqrt number) 
Example 1:
(sqrt 4) ; This will return 2. 
The square root of 4 is 2.
Example 2:
(sqrt 9) ; This will return 3. 
The square root of 9 is 3.
expt
Definition: Raises a number to a specified power.
Syntax:
(expt number power) 
Example 1:
(expt 2 3) ; This will return 8. 
This raises 2 to the 3rd power, resulting in 8.
Example 2:
(expt 3 2) ; This will return 9. 
Here, 3 is raised to the 2nd power, giving 9.
gcd
Definition: Returns the greatest common divisor of two integers.
Syntax:
(gcd int1 int2) 
Example 1:
(gcd 12 15) ; This will return 3. 
The greatest common divisor of 12 and 15 is 3.
Example 2:
(gcd 14 28) ; This will return 14. 
The greatest common divisor of 14 and 28 is 14.
rem
Definition: Returns the remainder after division.
Syntax:
(rem number divisor) 
Example 1:
(rem 10 3) ; This will return 1. 
The remainder when 10 is divided by 3 is 1.
Example 2:
(rem 15 4) ; This will return 3. 
Here, the remainder when 15 is divided by 4 is 3.
In conclusion, advanced number manipulations are not just essential; they are the backbone of intricate calculations in the AutoLISP language. Equipped with these functions, developers can navigate from the rudiments of simple arithmetic to the intricacies of complex trigonometric functions with ease and precision. Their versatility cannot be overstated. It’s paramount to practice these functions regularly, ensuring they become second nature. This consistent practice is the key to mastering their application, leading to a more profound and nuanced understanding. As you harness these tools, remember that the vast and dynamic world of CAD design eagerly anticipates the innovative solutions and designs you’ll bring to life with your bolstered expertise!