Category : Files from Magazines
Archive   : CUJ9208.ZIP
Filename : 1008052A

 
Output of file : 1008052A contained in archive : CUJ9208.ZIP
/* Listing 5 */
/*****************************************************
Name: EXAMPLE.C
Description: Example program for ray / surface
intercepts
Portability: Standard C, MSC with GRAPHICS_ON
*****************************************************/

#include
#define GRAPHICS_ON
#if defined( GRAPHICS_ON )
#include
#endif
#include
#include
#include

void main( void )
{
double T[3], Ip[3], DirH[3], DirV[3],
IpH[MAX_NUM_INCP], IpV[MAX_NUM_INCP],
Offset, MinH = 0.0, MaxH = 10.0, MinV = 0.0,
MaxV = 10.0, LocH[3], LocV[3], LocHAxis,
LocVAxis, StpHAxis, StpVAxis;
matrix_t C;
size_t i, NmSteps = 100;
int NmIpH = 0, NmIpV = 0, IpNm;

/* Create a matrix and fill with coefficients
** for a sphere with radius 5. */
C = cr_matrix( 4, 4 );
C[1][1] = C[2][2] = C[3][3] = 0.2; C[0][3] = 2;

/* Translate the sphere to x = 5, y = 5, z = 5 */
T[0] = T[1] = T[2] = -5.0;
srf_trans( C, T );

#if defined( GRAPHICS_ON )
/* put screen in graphics mode. */
_setvideomode( _MRESNOCOLOR );
#endif

/* Loop through some contours */
StpHAxis = ( MaxH - MinH ) / NmSteps;
StpVAxis = ( MaxV - MinV ) / NmSteps;
for ( Offset = 0.0; Offset < 5.0; Offset += 2.0 )
{
/* Loop through all the pixels. */
for ( i = 1, LocHAxis = MinH + StpHAxis,
LocVAxis = MinV + StpVAxis;
( i <= NmSteps ) &&
( LocHAxis <= MaxH ) &&
( LocVAxis <= MaxV );
i++, LocHAxis += StpHAxis,
LocVAxis += StpVAxis )
{
/* Start a ray in the horizontal
** direction going to the right.
** Start a ray in the Vical
** direction goting up. X is horizontal,
** Y is the Vical, Z is normal. */
DirH[0] = DirV[1] = 1.0;
DirH[1] = DirH[2] = 0.0;
DirV[0] = DirV[2] = 0.0;
LocH[0] = MinH;
LocH[1] = LocVAxis;
LocV[0] = LocHAxis;
LocV[1] = MinV;
LocH[2] = LocV[2] = Offset;
NmIpH = srf_intrcpt( 2, LocH, DirH, C, IpH );
NmIpV = srf_intrcpt( 2, LocV, DirV, C, IpV );
for ( IpNm = 0; IpNm < NmIpH; IpNm++ )
{
Ip[0] = LocH[0] + IpH[IpNm];
Ip[1] = LocH[1];
#if defined( GRAPHICS_ON )
_setpixel( (short)( Ip[0] / MaxH *
320.0 ), (short)( Ip[1] /
MaxV * 200.0 ) );
#else
printf( "%g,\t%g,\t%g\n", Ip[0], Ip[1],
Offset );
#endif
}
for ( IpNm = 0; IpNm < NmIpV; IpNm++ )
{
Ip[0] = LocV[0];
Ip[1] = LocV[1] + IpV[IpNm];
#if defined( GRAPHICS_ON )
_setpixel( (short)( Ip[0] / MaxH *
320.0 ), (short)( Ip[1] /
MaxV * 200.0 ) );
#else
printf( "%g,\t%g,\t%g\n", Ip[0], Ip[1],
Offset );
#endif
}
} /* for i */
} /* for Offset */
fr_matrix( C, 4 );
} /* function main */
/* End of File */


  3 Responses to “Category : Files from Magazines
Archive   : CUJ9208.ZIP
Filename : 1008052A

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/