home *** CD-ROM | disk | FTP | other *** search
- ---------------------------------------------------------------------------
- --This simple UPL program provides an easy way to insert circles which are
- --normal to a given line, at a given radius and have their origin at the
- --ends of the line
- --
- --Norman Case 05-22-86
- ---------------------------------------------------------------------------
-
- PROC LINE_CIRCLE(IN COORD C1, C2; REAL R)
-
- --This is a simple PROCedure to inserts a circle of radius R and origin at
- --C1, which is normal to the vector C1 to C2
-
- COORD C3, CE1, CE2, CE3
-
- C3 = VUNIT(C2-C1) --get unit vector along C1 C2
-
- IF C3.X <> 0.0 THEN
-
- --calculate a single point which is perpendicular to C3 at R distance
-
- CE1.Y = R/SQRT((C3.Y/C3.X)**2.0+1.0)
- CE1.X = -(C3.Y/C3.X)*CE1.Y
- ELSE
-
- --special case if X component of C3 is 0
-
- CE1.X = R
- CE1.Y = 0.0
- ENDIF
-
- CE1.Z = 0.0 --we are picking a point on the circle where Z = 0
-
- --calculate 2 other points that are on the circle
-
- CE2 = VCROSS(C3, CE1)
- CE3 = VCROSS(CE1, C3)
-
- --translate points back to C1
-
- CE1 = CE1+C1
- CE2 = CE2+C1
- CE3 = CE3+C1
-
- --insert circle given 3 points
-
- ECHO OFF
- SEND 'INS CIR:MODEL X ',CE1.X,' Y ',CE1.Y,'Z ',CE1.Z, \
- ',MODEL X ',CE2.X,' Y ',CE2.Y,'Z ',CE2.Z, \
- ',MODEL X ',CE3.X,' Y ',CE3.Y,'Z ',CE3.Z
- ECHO ON
-
- END PROC
-
- --------------------------------------------------------------------
-
- PROC MAIN
-
- CONST INTEGER MAX_ENT = 1
- INTEGER IENT, ETYP, MIL(MAX_ENT), NENT, IEND
- COORD C1, C2
- REAL R
-
- SEND ' ',
-
- --get radius
-
- ACCEPT R PROMPT(' radius ') LAST(' #13')
-
- LOOP
-
- --get lines to put circles on
-
- PRINT ' pick line ',
- GET_ENT(MAX_ENT, NENT, MIL(1), IEND)
-
- EXIT WHEN NENT = 0 OR LAST_CHAR = 3
-
- --loop through all picked entities
-
- LOOP IENT = 1 TO NENT
-
- --check the entity type
-
- VERIFY ENT_TYP(ETYP), ENT_ID(MIL(IENT))
- IF ETYP = 1 THEN
-
- --we got a line, now get end points of line
-
- VERIFY LINE ENT_ID(MIL(IENT)), ENDS(C1, C2)
-
- IF IEND = 1 THEN
- LINE_CIRCLE(C1, C2, R) --insert circle at end 1
- ELSE
- LINE_CIRCLE(C2, C1, R) --insert circle at end 2
- ENDIF
- ENDIF
- END_LOOP
-
- --if last character input was a cariage return then we are all done
-
- EXIT WHEN LAST_CHAR = 13
- END_LOOP
-
- END PROC
-