Icon routines 2 of 2 2/2

 BBS: Inland Empire Archive
Date: 07-02-92 (22:21)             Number: 231
From: MATT PRITCHARD @ 930/21      Refer#: NONE
  To: MIKE THAYER                   Recvd: NO  
Subj: Icon routines 2 of 2  2/2      Conf: (2) Quik_Bas
>>> Continued from previous message
You can change the pattern by changing the "sub-vectors"
that make up a pattern.  Perpendicular vectors (lines) are
easy because all you have to do is swap the X and Y values
and flip the sign of one of them. You can make diagional
line relative to the main line by adding two perpendicular
mini-vectors together...  For example:

        FOR Z = 1 TO N         ' # of patterns to make

          'Follow direct line to point B
          CALL MOVE.VECTOR( Sx!, Sy!, Vx2!, Vy2!, 7 )

          'Hook it 45 deg to right (90 deg to right + parallel)
          CALL MOVE.VECTOR( Sx!, Sy!, Vx3!+Vx2!, Vy3!+Vy2!, 7 )

          'Hook it 90 deg to left, getting back origional line
          CALL MOVE.VECTOR( Sx!, Sy!, Vx4!, Vy4!, 7 )

        NEXT Z


(Shelling out to try the code I just wrote)

It works fine.  Try changing the X2 and Y2 values around!
It automatically adjusts to the slope of the line.  No Trig
Math required!

The secret to understaing it is this:  To get from point A to point B, you
travel along a Vector V.  A mini-vector is just one-Nth of
the trip. Repeat it N times, and you are at your
destination.  Instead of just going staight along the mini-
vector, you take a bunch of "sub-vectors". As long as all
of the "sub-vectors" add up to the mini-vector, you are in
business.  How many and what kind of sub-vectors doesn't
matter. Just so long as when you add up all  of the X and Y
components, they equal the X and Y component of the mini-
vector.


Want to make a line of variable length a fixed pattern
width?  Just take the lenght of the overall line (LineLen!=
SQR( (X2-X1)^2 + (Y2-Y1) ^2 ) and divide by desired width
and you get your value for N!  You may want to watch out
for fractional value.  Maybe just take the Integer of N and
then recompute your width.  I'll cause a slight variance in
pattern widths but will make a line break up into a even
number of pattern units.

Well, I could go on for a while, but I'll let you chew on this.

-Hope it helps!

-Matt Pritchard

===
 * SLMR 2.1a * On a clear disk you can seek forever

--- InterPCB 1.50
 # Origin: CENTRAL BBS -Texas' BEST BBS! 214-393-7090 HST  3+GIGs (8:930/21)
 * Origin: Gateway System to/from RBBS-NET (RBBS-PC 1:10/8)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET