home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!destroyer!caen!sdd.hp.com!cs.utexas.edu!rutgers!dziuxsolim.rutgers.edu!psi.rutgers.edu!ib.rl.ac.uk!CDO
- From: CDO@IB.RL.AC.UK (C D Osland)
- Newsgroups: comp.graphics.visualization
- Subject: Re: Arrowhead plotting routine, anybody?
- Message-ID: <9207281633.AA13042@psi.rutgers.edu>
- Date: 28 Jul 92 16:15:33 GMT
- References: <craven@CA.EMR.CG>
- Sender: nobody@psi.rutgers.edu
- Lines: 126
-
- On 28 Jul 92 15:12:32 GMT <craven@CA.EMR.CG> said:
- >I ask this questions to avoid re-inventing the wheel.
- >
- >I am looking for a subroutine that given the head and tail
- >positions of a vector will calculate positions to
- >move to in order to draw an arrow head. Has anybody
- >done this before?
- >
- >Jim
- The following section of Fortran MIGHT be useful - it is for
- a solid (i.e. filled area) arrow, with more hard-wired than
- should be. I have adapted the code for this message, as there
- was a lot of extra code in the original section.
-
- *
- * 'P' - generate a pointer
- *
-
- * On entry, NP = 1,2,3 or 4:
- *
- * 1: two ends given, one arrow head
- * 2: two ends given, two arrow heads
- * 3: one end, length and angle given, one arrow head
- * 4: one end, length and angle given, two arrow heads
- *
- * (These values are actually read in below.)
- *
- * PWIDTH = pointer width
- * PSIZE = pointer length
- * RADFAC = conversion factor from degrees to radians
- *
- 95 CONTINUE
- IF (NP.EQ.0) GOTO 96
- IF ((NP.LT.1).OR.(NP.GT.4)) GOTO 96
- IPTYPE = NP
-
- 96 CONTINUE
-
- IF (IPTYPE.LT.3) THEN
- READ (INFILE,*,END=180) X1,Y1,X2,Y2
- ANGLE = ATAN2(Y2-Y1,X2-X1)
- ELSE
- READ (INFILE,*,END=180) X1,Y1,ALEN,ANGLE
- ANGLE = ANGLE * RADFAC
- X2 = X1 + ALEN * COS(ANGLE)
- Y2 = Y1 + ALEN * SIN(ANGLE)
- ENDIF
-
- X1 = X1 * FX + DX
- Y1 = Y1 * FY + DY
- X2 = X2 * FX + DX
- Y2 = Y2 * FY + DY
-
- PP = PSIZE
- RC = COS(ANGLE)
- RS = SIN(ANGLE)
-
- XXX(1) = X2
- YYY(1) = Y2
-
- XT = X2 - PP * RC
- YT = Y2 - PP * RS
- XXX(2) = XT + PSIZE * RS
- YYY(2) = YT - PSIZE * RC
-
- XXX(3) = XT + PWIDTH * RS
- YYY(3) = YT - PWIDTH * RC
-
- IF (MOD(IPTYPE,2).EQ.0) THEN
-
- * User has requested arrow heads at both ends
-
- NP = 11
- XT = X1 + PP * RC
- YT = Y1 + PP * RS
- XXX(4) = XT + PWIDTH * RS
- YYY(4) = YT - PWIDTH * RC
-
- XXX(5) = XT + PSIZE * RS
- YYY(5) = YT - PSIZE * RC
-
- XXX(6) = X1
- YYY(6) = Y1
-
- XXX(7) = XT - PSIZE * RS
- YYY(7) = YT + PSIZE * RC
-
- XXX(8) = XT - PWIDTH * RS
- YYY(8) = YT + PWIDTH * RC
-
- ELSE
-
- * User has requested arrow head only at X2,Y2 end
-
- NP = 8
- XXX(4) = X1 + PWIDTH * RS
- YYY(4) = Y1 - PWIDTH * RC
-
- XXX(5) = X1 - PWIDTH * RS
- YYY(5) = Y1 + PWIDTH * RC
-
- ENDIF
-
- XT = X2 - PP * RC
- YT = Y2 - PP * RS
- XXX(NP-2) = XT - PWIDTH * RS
- YYY(NP-2) = YT + PWIDTH * RC
-
- XXX(NP-1) = XT - PSIZE * RS
- YYY(NP-1) = YT + PSIZE * RC
-
- XXX(NP) = XXX(1)
- YYY(NP) = YYY(1)
-
- * GKS call to perform FILL AREA
-
- CALL GFA (NP,XXX,YYY)
- IRET = 0
- RETURN
- * Sorry about lack of comments!!!
-
- Zero copyright protection - use at will - not the code I'm most proud of!
-
- Cheers
-
- Chris Osland
-