Path: news.uiowa.edu!chi-news.cic.net!newsxfer2.itd.umich.edu!gatech!news.mathworks.com!news.kei.com!nntp.coast.net!harbinger.cc.monash.edu.au!news.uwa.edu.au!jturner
From: jturner@tartarus.uwa.edu.au (Joseph Turner)
Newsgroups: comp.sys.apple2.programmer
Subject: ORCA/C program problem
Date: 20 Jan 1996 14:53:47 GMT
Organization: The University of Western Australia
Lines: 116
Message-ID: <4dqvlr$3oo@styx.uwa.edu.au>
NNTP-Posting-Host: tartarus.uwa.edu.au
X-Newsreader: TIN [version 1.2 PL2]
Hello All, I have just got myself ORCA/c and have started to try and
write programs in this language that I used to write in Applesoft. I
however am having lots of annoying problems, which I have NO idea why
they are happening. Before I go any further I'll just give a brief
description of my sys just so the full picture is known.
rom 1
4 megs ram with 2 megs allocated to bootable ramdisk.
Orca version is 2.01
So here is the program.
#include
#include
#include
void main(void)
{
float x[4],y[4],z[4]; /*x,y,z co-ordinates*/
float pi; /*defining pi*/
int i; /*Used in loops*/
float sc,p,b; /*scaling factor and other constants used in calculations*/
float nx,ny; /*tempory variables used in calculations*/
float cx,cy; /*Centre postion*/
float sx,sy; /*Screen Co-ordinates*/
float cosangle, sinangle, theta; /*cos and sine of theta*/
/*Initialize Graphics*/
SetPenSize(2,1);
/*Initialize points*/
x[0]= 0; y[0] = 0; z[0]= 0;
x[1]= 10; y[1] = 0; z[1]= 0;
x[2]= 10; y[2] =10; z[2]= 0;
x[3]= 0; y[3] = 10; z[3]= 0;
x[4]= 0; y[4] = 0; z[4]= 0;
cx=300;cy=100;
pi=3.141592653;
theta= pi/4;
cosangle = cos(theta);
sinangle = sin(theta);
sc = 5;
p = 100;
b = 250;
i = 0;
x[i] = x[i] * sc;
y[i] = y[i] * sc;
z[i] = z[i] * sc;
nx = cosangle * x[i] + sinangle * y[i];
ny = cosangle * y[i] - sinangle * x[i];
x[i] = nx;
y[i] = ny;
sx = x[i] * b/(b+y[i]);
sy = z[i] + (p-z[i])*y[i]/(b+y[i]);
sx = sx + cx;
sy = cy - sy;
MoveTo(sx,sy);
for (i=0; i<=4; ++i) {
x[i] = x[i] * sc;
y[i] = y[i] * sc;
z[i] = z[i] * sc;
nx = cosangle * x[i] + sinangle * y[i];
ny = cosangle * y[i] - sinangle * x[i];
x[i] = nx;
y[i] = ny;
sx = x[i] * b/(b+y[i]);
sy = z[i] + (p-z[i])*y[i]/(b+y[i]);
sx = sx + cx;
sy = cy - sy;
LineTo(sx,sy);
printf("%f,%f\n",sx,sy)
}
}
The program is just a three-d program which just transforms a square in
3d to the screen. The algorithms have been used in applesoft and so they
are known to definitly work.
When I complie the code, the program seems to execute as I would, ie it
draws the rectangle, but then immediately after beeps and puts me into
the monitor,(the IIgs freezes and so I press control reset, and from what
is on the screen , it is obvious that it went into the monitor).
And of course no errors were reported.
I have tried many other programs and they seem to have no problem. This
is my own creation, does anyone know what I have done wrong?
Thanks in advance for any help.
Joe