Function Definitions

2  -  Geometry & Trigonometry

distance ..... Returns the 3D distance between two points.

(distance (list 1 1 0) (list 2 2 0))  returns 1.41421
(distance (list 0 0 0) (list 2 2 8))  returns 8.48528
After (setq p1 (list 4.1 2.2) p2 (list 7.1 2.2))
(distance p1 p2)  returns 3.0


angle ..... Returns angle in radians between two points in the current UCS.  All points are projected onto the current X-Y construction plane.

(angle (list 2.0 2.0) (list 3.0 3.0))  returns 0.785398
After (setq p1 (list 6.0 2.0) p2 (list 3.0 2.0))
(angle p1 p2)  returns 3.14159


polar ..... Returns the point that is located at a certain angle and a certain distance from a given point.  The first argument is the base point.  The second argument is the angle in radians.  The third argument is the distance.

(polar (list 2 2) 2.356195 6.0)  returns the coordinates of the point that is 6 units at angle 2.356195 radians from 2,2
After (setq p1 (list 8 1 0) a (/ pi 3) d 2.5)
(polar p1 a d)  returns the coordinates of the point that is 2.5 units at angle 60 degrees (/ pi 3) from 8,1,0

If the base point is a 2D point (no Z coordinate given), then a 2D point is returned.  If the base point is a 3D point, then the returned point will have the same Z coordinate as the base point.  The angle is always measured in the XY construction plane of the current UCS.


inters ..... Returns point of intersection of two non-parallel lines

(inters '(1 1) '(2 2) '(1 2) '(2 1) T) returns (1.5 1.5), which are the coordinates of a point at the intersection of the line joining 1,1 and 2,2 and the line joining 1,2 and 2,1

The fifth argument ("T") is optional. If it is omitted or if it is T (or any non-nil expression) the intersection point must lie on both lines. If it is nil, the intersection point can be off the end of one or both lines.

After (setq p '(0 0) q '(9 9) r '(6 0) s '(5 1))
(inters p q r s)  returns nil
(inters p q r s T)  returns nil
(inters p q r s nil)  returns (3.0 3.0)
(inters (list 2 2 2) (list 2 0 4) (list 2 4 2) (list 2 6 4) nil)  returns (2.0 3.0 1.0)
(inters (list 2 2 2) (list 2 0 4) (list 2 4 2) (list 1 6 4) nil)  returns nil because the lines do not lie in the same plane

Remember that all points in variables are interpreted in the current UCS even if they were established in a different UCS. Use the trans function to translate points from one UCS to another.  See trans under "14 - Working with AutoCAD."


sin ..... Returns sine of angle (angle is in radians)

(sin 0.5)  returns 0.479425
(sin (* pi 0.25))  returns 0.707106
(sin (* pi 1.25))  returns -0.707106


cos ..... Returns cosine of angle (angle is in radians)

(cos 0.5)  returns 0.877583
(cos (* pi 0.25))  returns 0.707107
(cos (* pi 0.75))  returns -0.707107


atan ..... Returns arctangent (in radians) of one number or of the quotient of two numbers

(atan 1.0)  returns 0.785398
(atan -0.5)  returns -0.463648
(atan 7.5 2.5)  returns 1.24905 (the arc whose tangent is 7.5 divided by 2.5)

If one argument is used, the range of angles returned is from -pi/2 to +pi/2 radians and the sign of the angle is the same as the sign of the argument.  If two arguments are used the range of angles returned is from -pi to + pi radians and the sign of the angle is the same as the sign of the first argument.



 
HOME

Copyright © 1988, 1998 Ronald W. Leigh