util/geometry.lsp [src]
Functions related to points, vectors, and planes
(add-bulges pts)
Returns point list PTS with all points padded to 3D
(angle-between a1 a2)
Returns the angle between angles A1 and A2 (radians)
(bend-deduct thick ang rad k)
Calculates a bend deduction
THICK is the material thickness. ANG is the excluded bend angle in degrees. RAD is the
bend radius. K is the K-value.
(calc-angles pts)
Returns a list of internal angles between PTS
(calc-bulge ang)
Returns the bulge value corresponding to a fillet of ANG radians
(calc-fillet pt1 pt2 pt3 radius)
Calculates a fillet for three 2D points at RADIUS
All points should be 2D. The return value will be a list of four 3D points, with the Z
coordinate representing the bulge.
VARS:
(PT1 LIST (POINT-P PT1))
(PT2 LIST (POINT-P PT2))
(PT3 LIST (POINT-P PT3))
(RADIUS nil (NUMBERP RADIUS))
(calc-segs pts)
Returns a list of segment lengths between points in PTS
Holds the minimum starting segment at 6" and the ending segment at 18" for pipe
bending.
VARS:
(PTS nil (LISTP PTS) (VL-EVERY 'POINT-P PTS))
(cross-product v1 v2)
Returns the cross product of vectors V1 and V2
VARS:
(V1 LIST (VL-EVERY 'NUMBERP V1) (= (LENGTH V1) 3))
(V2 LIST (VL-EVERY 'NUMBERP V2) (= (LENGTH V2) 3))
(dihedral v1 v2)
Returns the dihedral angle between two planes defined as normal vectors
VARS:
(V1 LIST (VL-EVERY 'NUMBERP V1) (= (LENGTH V1) 3))
(V2 LIST (VL-EVERY 'NUMBERP V2) (= (LENGTH V2) 3))
(dirmirror pts)
Return PTS mirrored according to DIR
VARS:
(PTS LIST)
(displace-pt pt d)
Returns point PT displaced by point D
VARS:
(PT (LIST nil) (IF PT (POINT-P PT) T))
(D (LIST nil) (IF D (POINT-P D) T))
TESTS:
(EQUAL (DISPLACE-PT '(0 0) '(2 2)) '(2 2))
(EQUAL (DISPLACE-PT '(1 2) '(3 4)) '(4 6))
(displace-pts pts d)
Returns points list PTS with all points displaced by point D
VARS:
(PTS nil (PTS-LIST-P PTS))
(D nil (POINT-P D))
TESTS:
(EQUAL (DISPLACE-PTS '((0 0) (1 1)) '(2 2)) '((2 2) (3 3)))
(fillet-all-pts pts radius)
Returns points list PTS with all corners filleted to RADIUS
See calc-fillet for individual fillet calculations.
(int-ang p1 p2 p3)
Return the internal angle of 3 points in radians
(join-vertices lines)
Joins a list of lines
LINES should be a list of lines (lists of points). If the last point of one line equals the
first point of the next, they are joined into one. Otherwise, they are left separate.
VARS:
(LINES nil (LISTP LINES) (VL-EVERY '(LAMBDA (LINE) (VL-EVERY 'POINT-P LINE)) LINES))
TESTS:
(EQUAL (JOIN-VERTICES '(((0 0) (1 0)) ((1 0) (1 1)) ((1 2) (0 2)))) '(((0 0) (1 0) (1 1)) ((1 2) (0 2))))
(mid-2-pts p1 p2)
Returns a 2D point which is midway between P1 and P2
(mirror-pts-h pts y)
Returns points list PTS mirrored over horizontal line at Y
VARS:
(PTS LIST (VL-EVERY 'POINT-P PTS))
(Y nil (NUMBERP Y))
TESTS:
(EQUAL (MIRROR-PTS-H '((0 0) (1 1)) 0) '((0 0) (1 -1)))
(mirror-pts-v pts x)
Returns points list PTS mirrored over vertical line at X
VARS:
(PTS LIST (VL-EVERY 'POINT-P PTS))
(X nil (NUMBERP X))
TESTS:
(EQUAL (MIRROR-PTS-V '((0 0) (1 1)) 0) '((0 0) (-1 1)))
(norm_3pts org xdir ydir)
Returns a normal vector based on an origin x vector and y vector
VARS:
(ORG LIST POINT-P)
(XDIR LIST POINT-P)
(YDIR LIST POINT-P)
(normal-vec pt1 pt2 pt3)
Returns the 3D vector normal to 3 points
(pipe-bend-lines segments-lst)
Returns the bend lines for a PSC pipe with segments SEGMENTS-LST
Each element to SEGMENTS-LST should be a real number. Assumes 1.66OD pipe, centerline
radius of 2.83" and k value of 0.18.
(pipe-bend-lines-padded segments-lst)
Wrapper for pipe-bend-lines that always returns a 9-item list to match fab drawing tables
(point-p pt)
Returns T if PT is a 2- or 3-item list of numbers
(pts-list-p pts-list)
Returns T if PTS-LIST is a list of points
(rect-pts width height ins)
Returns the points list for a rectangle located at point INS
VARS:
(WIDTH nil (NUMBERP WIDTH))
(HEIGHT nil (NUMBERP HEIGHT))
(INS LIST (POINT-P INS))
TESTS:
(EQUAL (RECT-PTS 1 1 '(0 0)) '((0 0) (1 0) (1 1) (0 1)))
(EQUAL (RECT-PTS 1 2 '(3 4)) '((3 4) (4 4) (4 6) (3 6)))
(rezero-pts pts v)
Returns points list PTS recentered on the Vth vertex
Rotates the list around until V is the 0th item and displaces the points so they are
correct. Adds Z coordinates if 2D.
VARS:
(PTS nil (PTS-LIST-P PTS))
(V INT (>= V 0) (<= V (LENGTH PTS)))
TESTS:
(EQUAL (REZERO-PTS '((0 0) (1 1)) 1) '((0 0 0) (-1 -1 0)))
(rotate-pt pt ang)
Returns point PT rotated about the origin by ANG (radians)
Adds Z coordinate if 2D.
VARS:
(PT nil (POINT-P PT))
(ANG nil (NUMBERP ANG))
(rotate-pts pts ang)
Return points list PTS with all points rotated about the orgin by ANG (radians)
Adds Z coordinates if 2D.
(safe-calc-fillet-3d pts-lst rad)
Repeats calc-fillet-3d with reduced radius until no error is returned
VARS:
(PTS-LST LIST (VL-EVERY 'POINT-P PTS-LST) (VL-EVERY 'CDDR PTS-LST))
(RAD nil (NUMBERP RAD))
(vec- v1 v2)
Returns the result of subtracting vector V1 from V2
VARS:
(V1 LIST (VL-EVERY 'NUMBERP V1) (= (LENGTH V1) 3))
(V2 LIST (VL-EVERY 'NUMBERP V2) (= (LENGTH V2) 3))
(within-box-p pt boxpt1 boxpt2)
Returns T if PT is within the box defined by BOXPT1 and BOXPT2
VARS:
(PT LIST (POINT-P PT))
(BOXPT1 LIST (POINT-P BOXPT1))
(BOXPT2 LIST (POINT-P BOXPT2))
TESTS:
(WITHIN-BOX-P '(0 0) '(-1 -1) '(1 1))
(NOT (WITHIN-BOX-P '(10 10) '(0 0) '(1 1)))