[MWForum]figure generator

Jeff Knope mwforum@lists.mathcats.com
Wed, 1 Jan 2003 23:30:47 -0800


This is a multi-part message in MIME format.

------=_NextPart_000_000F_01C2B1ED.CFD3B980
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_0010_01C2B1ED.CFD3B980"


------=_NextPart_001_0010_01C2B1ED.CFD3B980
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Daniel Ajoy, et al-

I'm completely new to forums of any sort, and am unsure of the protocol. =
 I suspect I should be doing a "reply to" - but frankly, what I got in =
reply was a huge bunch of stuff: what I'd written, then what I'd written =
imbedded in HTML, then Daniel's response, then about 300 lines the first =
of which was:
R0lGODlhNgFKAfcAAAQCBPz+/AQC/PwCBEADFzoAAwAA+AAAZAA/gQAZAP8ABxUAAwDvAQAR
the remaining 299 more of the same.  If I do a "reply to" you'll just =
get all that gibberish right back.  So I'm starting over with a clean =
piece of paper.  If there's some sort of setting for me to make in my =
mail program or something, I'd appreciate some help with that.

Maybe all that gibberish had to do with Daniel's attachment, but there =
was no paperclip or anything, and I didn't get the attachment.

Anywho, I'm including an attachment of the procedures you asked about =
(sans the arc - I'll deal with it separately later), along with some =
introductory explanations.  I hope it's useful.

Regards,
-JEFF

------=_NextPart_001_0010_01C2B1ED.CFD3B980
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2722.900" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Daniel Ajoy, et al-</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'm completely new to forums of any =
sort, and am=20
unsure of&nbsp;the protocol.&nbsp; I suspect I should be doing a "reply =
to" -=20
but frankly, what I got in reply was a huge bunch of stuff: what I'd =
written,=20
then what I'd written imbedded in HTML, then Daniel's response, then =
about 300=20
lines the first of which was:</FONT></DIV>
<DIV>R0lGODlhNgFKAfcAAAQCBPz+/AQC/PwCBEADFzoAAwAA+AAAZAA/gQAZAP8ABxUAAwDv=
AQAR</DIV>
<DIV>the remaining 299 more of the same.&nbsp; If I do a "reply to" =
you'll just=20
get all that gibberish right back.&nbsp; So I'm starting over with a =
clean piece=20
of paper.&nbsp; If there's some sort of setting for me to make in my =
mail=20
program or something, I'd appreciate some help with that.</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Maybe all that gibberish had to do with =
Daniel's=20
attachment, but there was no paperclip or anything, and I didn't get the =

attachment.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anywho, I'm including an attachment of =
the=20
procedures you asked about (sans the arc - I'll deal with it separately =
later),=20
along with some introductory explanations.&nbsp; I hope it's=20
useful.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Regards,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>-JEFF</FONT></DIV></BODY></HTML>

------=_NextPart_001_0010_01C2B1ED.CFD3B980--

------=_NextPart_000_000F_01C2B1ED.CFD3B980
Content-Type: application/octet-stream;
	name="Fog to Daniel.rtf"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="Fog to Daniel.rtf"

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fcharset0 =
Times New Roman;}{\f1\fnil Courier New;}{\f2\fnil\fcharset0 Courier =
New;}{\f3\fswiss\fcharset0 Arial;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\sb100\sa100\f0\fs24 2 Jan. '03\par
Hi Daniel-\par
Well, you asked for it....I'm afraid that a good deal of this code is =
specific to my application, and makes little sense outside that context. =
 Everything concerning "mag & "magnet & "chkpts & the many colors it's =
sensitive to, has to do with responding to other figures previously =
drawn or generated in my app, and should be excised.  References to =
REPORT have to do with writing to little textboxes the distances =
traversed in feet and inches in the scale of my app - and should also be =
excised.  Text39 is a user prompt for the correct keys to implement the =
different modes and options expressed in GETMODE.  The stuff about =
REVERSE and DEFLECT has to do with the fact my app needs all the closed =
figures in counter-clockwise order, but users often don't cooperate.  =
CLEANUP, CLEANFIG, TSTANG & TESTANG get rid of redundant and backtracked =
points created by users wanting to make doubly sure that point is in =
there.  Somehow, it all adds up to a fairly bulletproof deal.  At the =
end, the whole figure is redrawn with DRAWFIG, because the =
rubber-banding sometimes leaves little gaps in the image.\par
The key procedures are ORTHO (which is misnamed) and DOPT (read "do =
point").  At the end, I've included the TOWARD I spoke of, and ANG, =
which measures the interior angle of two joined segments.\par
Good Luck!\par
-JEFF\par
\par
\par
\pard\cf1\f1\fs20 TO FOG           ;basic figure generator\par
make "fig []\par
if not :chkpts =3D [] [make "mag "on tto "mask ht tto "cross]\par
forever [GETMODE]\par
tto "cross \par
ht\par
make "mode 3\par
pu\par
set "text39 "visible? "true\par
set "yellow "mouseclick [DOPT]\par
set "black "mouseclick [DOPT]\par
set "red "mouseclick [DOPT]\par
set "blue "mouseclick [DOPT]\par
set "green "mouseclick [DOPT]\par
make "col color\par
forever [REPORT]\par
ORTHO\par
set "text39 "visible? "false\par
set "yellow "mouseclick []\par
set "black "mouseclick []\par
set "red "mouseclick []\par
set "blue "mouseclick []\par
set "green "mouseclick []\par
cancel [GETMODE]\par
CLEANUP\par
TESTANG\par
if :deflects =3D -360 [REVERSE]\par
pu\par
end\par
\par
TO REVERSE           ;makes clockwise into ccwise\par
make "tempfig []\par
RVRS :fig\par
make "fig :tempfig\par
end\par
\par
TO RVRS :pts         ;see above\par
if :pts =3D [] [stop]\par
make "tempfig fput first :pts :tempfig\par
RVRS bf :pts\par
end\par
\par
TO CLEANUP         ;see above - purges redundancies\par
make "tempfig []\par
CLEANFIG bf :fig\par
make "fig :tempfig\par
make "fig fput last :fig :fig\par
end\par
\par
TO CLEANFIG :pts         ;see above\par
if (count :pts) =3D 1 [make "tempfig lput first :pts :tempfig stop]\par
if not member? first :pts bf :pts [make "tempfig lput first :pts =
:tempfig]\par
CLEANFIG bf :pts\par
end\par
\par
TO TESTANG       ;purges backtracks & tracks rotation\par
make "tempfig []\par
make "deflects 0\par
make "fig lput first bf :fig :fig\par
TSTANG :fig\par
make "tempfig fput last :tempfig :tempfig\par
make "fig :tempfig\par
end\par
\par
TO TSTANG :pts                   ;see above\par
if (count :pts) =3D 2 [stop]\par
ANG (list first :pts first bf :pts first bf bf :pts)\par
if and not :ang =3D 0 not :ang =3D 360 [make "tempfig lput first bf :pts =
:tempfig DEFLECT make "deflects :deflects + :dflt]\par
TSTANG bf :pts\par
end\par
\par
TO DEFLECT                  ;see above\par
ifelse :ang > 180 [make "dflt (180 - :ang)][make "dflt :ang]\par
end\par
\par
TO GETMODE          ;called by FOG\par
let [key readchar]\par
;;;What is mode 1 for? Right now it is "mag\par
if :key =3D "m [mag]              ;magnet on/off\par
if :key =3D "r [make "mode 3]     ;rectangular\par
if :key =3D "d [make "mode 2]     ;diagonal\par
if :key =3D "c [make "mode 4]     ;close\par
if :key =3D "u [make "mode 5]     ;undo\par
if :key =3D "e [make "mode 6]     ;end\par
end\par
\par
;break up ORTHO into different units?\par
\par
TO ORTHO             ;called by FOG\par
;if :mode =3D 1 [tto "mask ifelse :mag =3D "on [st make "mag "off][ht =
make "mag "on] tto "cross]\par
if :mode =3D 7 [setc 9 setpos mousepos setpos last :fig waituntil [:mode =
> 1]]\par
if not :fig =3D [] [if and (last mousepos) > -235 :mode =3D 3 [make "x =
(first mousepos) - (first last :fig) make "y (last mousepos) - (last =
last :fig) ifelse (abs :x) > (abs :y) [pd setc 9 setpos last :fig setc =
:col setx first mousepos sety last last :fig][pd setc 9 setpos last :fig =
setc :col sety last mousepos setx first last :fig]] if and (last =
mousepos) > -235 :mode =3D 2 [setc 9 setpos last :fig setc :col setpos =
mousepos]]\par
if :mode =3D 4 [setc 9 setpos last :fig setc :col setpos first :fig make =
"fig lput first :fig :fig make "mode 1 waituntil [:mode > 1]]\par
if :mode =3D 5 [ifelse (count :fig) > 1 [setc 9 setpos last :fig pd =
setpos last bl :fig make "fig bl :fig make "mode 1 waituntil [:mode > =
1]][make "fig [] pu make "mode  3]]\par
if :mode =3D 6 [cancel [REPORT] setc 9 setpos mousepos setpos last :fig =
setc :col DRAWFIG :fig pu tto "mask st tto "cross stop]\par
ORTHO\par
end\par
\par
TO DOPT               ;see above\par
make "pt mousepos\par
if and (not :chkpts =3D []) :mag =3D "on [make "close 4 CHECK =
:chkpts];;;NEED WORK\par
if :fig =3D [] [setpos :pt pd make "fig lput :pt :fig stop]\par
if :mode =3D 3 [ifelse (abs :x) > (abs :y) [make "fig lput list (first =
:pt) (last last :fig) :fig] [make "fig lput list (first last :fig) (last =
:pt) :fig]]\par
if :mode =3D 2 [make "fig lput :pt :fig]\par
end\par
\par
TO CHECK :pts            ;see above\par
if :pts =3D [] [stop]\par
make "a abs ((first :pt) - (first first :pts))\par
make "b abs ((last :pt) - (last first :pts))\par
if and :a < :close :b < :close [make "pt first :pts ifelse :a > :b [make =
"close :a][make "close :b]]\par
CHECK bf :pts\par
end\par
\par
TO MAG                  ;see above\par
tto "mask\par
ifelse :mag =3D "off [make "mag "on ht][make "mag "off st]\par
tto "cross\par
end\par
\par
TO REPORT                ;see above\par
ifelse :fig =3D [] [][make "xdist (abs(first last :fig) - (first =
mousepos)) set "\f2 Xtext\f1  "text (word (int :xdist / 6) "' "- round =
(((:xdist / 6) - int (:xdist / 6)) * 12) "") make "ydist (abs(last last =
:fig) - (last mousepos)) set "\f2 Ytext\f1  "text (word (int :ydist / 6) =
"' "- round (((:ydist / 6) - int (:ydist / 6)) * 12) "")]\par
end\par
\par
TO DRAWFIG :fig           ;basic figure drawer\par
pu setpos first :fig pd\par
DRWFIG bf :fig\par
END\par
\par
TO DRWFIG :fig             ;see above\par
if :fig =3D [] [pu stop]\par
setpos first :fig\par
DRWFIG bf :fig\par
end\par
\par
TO TOWARD :pt  ;;;sets heading\par
if (first :pt) =3D (first pos) [ifelse (last :pt) > (last pos) [seth 0 =
stop][seth 180 stop]];;;no divide by 0\par
make "slp ((last :pt) - (last pos)) / ((first :pt) - (first pos))\par
ifelse (first :pt) > (first pos) [seth minus ((arctan :slp) - 90)] [seth =
minus ((arctan :slp) + 90)]\par
end\par
\par
;;;(ANG takes 3-pt. list; measures clockwise;\par
;;; first pt.pair is start'g seg; second pt. is center)\par
\par
TO ANG :pts\par
local [hdga hdgb]\par
setpos first bf :pts\par
TOWARD first :pts make "hdga heading\par
TOWARD last :pts make "hdgb heading\par
ifelse :hdgb > :hdga [make "ang :hdgb - :hdga][make "ang :hdgb + 360 - =
:hdga]\par
end\par
\par
\cf0\f3\par
}
=00
------=_NextPart_000_000F_01C2B1ED.CFD3B980--