[net.sources] Relative plot_line

sewilco@mecc.UUCP (Scot E. Wilcoxon) (07/24/85)

My problem when trying to use the recently posted fractal curve
generators is probably moderately common for we on smaller
machines...  No routine to draw a line relative to the
current point.  Here's a version of plot_point which only needs a
line-drawing routine, and a suggestion of where to put system-
dependent definitions.

------------------You've got to cut somewhere.  Try here. -----------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	System.h
#	plot.c
# This archive created: Wed Jul 24 15:13:43 1985
export PATH; PATH=/bin:$PATH
if test -f 'System.h'
then
	echo shar: will not over-write existing file "'System.h'"
else
cat << \SHAR_EOF > 'System.h'
/*
 * System.h
 * 
 * System-dependent constants for convenience when doing radial fractal work
 *
 * Author: Scot E. Wilcoxon (mecc!sewilco)
 */

#ifndef SYSFUN
#define SYSFUN
#define XENIX3		/* We're using the peculiarities of XENIX 3.0 */
#define NORLINE		/* No Relative Line in the Lisa */
#include "../graphics.h"	/* Let's not forget local graphic values */
#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'plot.c'
then
	echo shar: will not over-write existing file "'plot.c'"
else
cat << \SHAR_EOF > 'plot.c'
/*
 * Plot_line()
 *
 * Draw a line by length and angle relative to current x,y
 *
 * Modifier: Scot E. Wilcoxon (mecc!sewilco)
 * (works for me, and it is free)
 *
 * Author: Jim Hutchison (hutch@sdcsvax)
 * (this is free, but credit me)
 */

#include "System.h"

#ifdef SUNSYS
#include <usercore.h>	/* This is probably for SUN's Suncore graphics. */
#endif

#include <math.h>
#include "g.h"

/*
 *	Plot a line by length and angle from current position
 */

plot_line(length,angle)
double length,angle;
{

#ifdef NORLINE
static	double	xhere = (MAXX / 2.0) ;
static	double	yhere = (MAXY / 2.0) ;
#endif

double dx,dy;

    MOD(angle,TWOPI);

    dx = length * cos(angle);
    dy = length * sin(angle);

#ifndef NORLINE
    line_rel_2( dx, dy);
#else
    line ((int)xhere, (int)yhere, (int)(xhere+dx), (int)(yhere+dy), opr_clr);
    xhere+=dx; yhere+=dy;
#endif
}
SHAR_EOF
fi # end of overwriting check
#	End of shell archive
exit 0
----------------
Enjoy.  Fractal a leg.

Scot E. Wilcoxon	Minn. Ed. Comp. Corp.     circadia!mecc!sewilco
45N03',93W15'	(612)481-3507 {ihnp4,mgnetp,uwvax}!dicomed!mecc!sewilco