Ejemplo n.º 1
0
double alpha(int jd) {
  double x = cos(Lambda(jd));
  double y = cos(oblique(jd)) * sin(Lambda(jd));
  double Alpha = atan(y / x);
  // Sign corresponds arctan2()
  if ((x < 0) && (y < 0)) Alpha = Alpha - PI;
  if ((x < 0) && (y > 0)) Alpha = Alpha + PI;
  return Alpha;
}
Ejemplo n.º 2
0
int main(void)
{
    char line_buffer[BUFSIZ];
    char *line;

    int input[BUFSIZ];
    int size = 0;
    int height = 0;

    // read input into int buffer and calculate size of 2D array
    while ((line = fgets(line_buffer, BUFSIZ-1, stdin)))
    {
        if (line[0] == '\n') break;
        char *buf;
        while ((buf = strsep(&line, " "))) 
        {
            if (sscanf(buf, " %d", &input[size]) != 1) continue;
            size++;
        }
        height++;
    }
    int width = size / height;

    // allocate a 2d array based on calculated size
    int **array = malloc(sizeof(int *) * height);
    int *rowptr = malloc(sizeof(int) * height * width);
    for (int i = 0; i < height; i++)
    {
        array[i] = rowptr + (i * width);
    }

    // assign input values to their array locations
    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width; j++)
        {
            array[i][j] = input[j + (i * width)];
        }
    }

    oblique(array, width);

    free(rowptr);
    free(array);
    return 0;
}
Ejemplo n.º 3
0
Archivo: font.cpp Proyecto: asir6/Colt
WT_Boolean    WT_Font::operator== (WT_Attribute const & attrib) const
{
    if (attrib.object_id()  == Font_ID                                  &&
        style()             == ((WT_Font const &)attrib).style()        &&
        charset()           == ((WT_Font const &)attrib).charset()      &&
        pitch()             == ((WT_Font const &)attrib).pitch()        &&
        family()            == ((WT_Font const &)attrib).family()       &&
        font_name()         == ((WT_Font const &)attrib).font_name()    &&
        height()            == ((WT_Font const &)attrib).height()       &&
        rotation()          == ((WT_Font const &)attrib).rotation()     &&
        width_scale()       == ((WT_Font const &)attrib).width_scale()  &&
        spacing()           == ((WT_Font const &)attrib).spacing()      &&
        oblique()           == ((WT_Font const &)attrib).oblique()      &&
        flags()             == ((WT_Font const &)attrib).flags()           )
        return WD_True;
    else
        return WD_False;
}
Ejemplo n.º 4
0
// Derived verb for f//. y
static DF1(jtobqfslash){A y,z;B b=0,p;C er,id,*wv;I c,d,k,m,m1,mn,n,n1,r,*s,wt;
 RZ(w);
 r=AR(w); s=AS(w); wt=AT(w); wv=CAV(w);
 if(!(AN(w)&&1<r&&DENSE&wt))R oblique(w,self);  // revert to default if rank<2, empty, or sparse
 y=VAV(self)->f; y=VAV(y)->f; id=vaid(y);
 m=s[0]; m1=m-1;
 n=s[1]; n1=n-1; mn=m*n; d=m+n-1; PROD(c,r-2,2+s);
 if(1==m||1==n){GA(z,wt,AN(w),r-1,1+s); *AS(z)=d; MC(AV(z),wv,AN(w)*bp(wt)); R z;}
 if(wt&FL+CMPX)NAN0;
 if(1==c)switch(OBQCASE(CTTZ(wt),id)){
  case OBQCASE(B01X, CNE     ): OBQLOOP(B,B,wt,x=*u, x^=*u        ); break;
  case OBQCASE(B01X, CEQ     ): OBQLOOP(B,B,wt,x=*u, x=x==*u      ); break;
  case OBQCASE(B01X, CMAX    ):
  case OBQCASE(B01X, CPLUSDOT): OBQLOOP(B,B,wt,x=*u, x|=*u        ); break;
  case OBQCASE(B01X, CMIN    ):
  case OBQCASE(B01X, CSTAR   ):
  case OBQCASE(B01X, CSTARDOT): OBQLOOP(B,B,wt,x=*u, x&=*u        ); break;
  case OBQCASE(B01X, CLT     ): OBQLOOP(B,B,wt,x=*u, x=*u< x      ); break;
  case OBQCASE(B01X, CLE     ): OBQLOOP(B,B,wt,x=*u, x=*u<=x      ); break;
  case OBQCASE(B01X, CGT     ): OBQLOOP(B,B,wt,x=*u, x=*u> x      ); break;
  case OBQCASE(B01X, CGE     ): OBQLOOP(B,B,wt,x=*u, x=*u>=x      ); break;
  case OBQCASE(B01X, CPLUS   ): OBQLOOP(B,I,INT,x=*u, x+=*u       ); break;
  case OBQCASE(SBTX, CMAX    ): OBQLOOP(SB,SB,wt,x=*u, x=SBGT(x,*u)?x:*u ); break;
  case OBQCASE(SBTX, CMIN    ): OBQLOOP(SB,SB,wt,x=*u, x=SBLT(x,*u)?x:*u ); break;
  case OBQCASE(FLX,  CMAX    ): OBQLOOP(D,D,wt,x=*u, x=MAX(x,*u)  ); break;
  case OBQCASE(FLX,  CMIN    ): OBQLOOP(D,D,wt,x=*u, x=MIN(x,*u)  ); break;
  case OBQCASE(FLX,  CPLUS   ): OBQLOOP(D,D,wt,x=*u, x+=*u        ); break;
  case OBQCASE(CMPXX,CPLUS   ): OBQLOOP(Z,Z,wt,x=*u, x=zplus(x,*u)); break;
  case OBQCASE(XNUMX,CMAX    ): OBQLOOP(X,X,wt,x=*u, x=1==xcompare(x,*u)? x:*u); break;
  case OBQCASE(XNUMX,CMIN    ): OBQLOOP(X,X,wt,x=*u, x=1==xcompare(x,*u)?*u: x); break;
  case OBQCASE(XNUMX,CPLUS   ): OBQLOOP(X,X,wt,x=*u, x=xplus(x,*u)); break;
  case OBQCASE(RATX, CMAX    ): OBQLOOP(Q,Q,wt,x=*u, x=1==QCOMP(x,*u)? x:*u); break;
  case OBQCASE(RATX, CMIN    ): OBQLOOP(Q,Q,wt,x=*u, x=1==QCOMP(x,*u)?*u: x); break;
  case OBQCASE(RATX, CPLUS   ): OBQLOOP(Q,Q,wt,x=*u, x=qplus(x,*u)); break;
  case OBQCASE(INTX, CBW0001 ): OBQLOOP(I,I,wt,x=*u, x&=*u        ); break;
  case OBQCASE(INTX, CBW0110 ): OBQLOOP(I,I,wt,x=*u, x^=*u        ); break;
  case OBQCASE(INTX, CBW0111 ): OBQLOOP(I,I,wt,x=*u, x|=*u        ); break;
  case OBQCASE(INTX, CMAX    ): OBQLOOP(I,I,wt,x=*u, x=MAX(x,*u)  ); break;
  case OBQCASE(INTX, CMIN    ): OBQLOOP(I,I,wt,x=*u, x=MIN(x,*u)  ); break;
  case OBQCASE(INTX, CPLUS   ): 
   er=0; OBQLOOP(I,I,wt,x=*u, {p=0>x; x+=*u; BOV(p==0>*u&&p!=0>x);}); 
   if(er>=EWOV)OBQLOOP(I,D,FL,x=(D)*u, x+=*u);
 }
Ejemplo n.º 5
0
Archivo: font.cpp Proyecto: asir6/Colt
WT_Result WT_Font::sync(WT_File & file) const
{
    WD_Assert( (file.file_mode() == WT_File::File_Write) ||
               (file.file_mode() == WT_File::Block_Append) ||
               (file.file_mode() == WT_File::Block_Write));

    if (*this != file.rendition().font())
    {
        // Find out which fields of the font definition have changed and only
        // output those sub-fields.

        ((WT_Font &)(*this)).m_fields_defined = 0;

        if (font_name()   != file.rendition().font().font_name())
            ((WT_Font &)(*this)).m_fields_defined |= FONT_NAME_BIT;
        if (charset()     != file.rendition().font().charset())
            ((WT_Font &)(*this)).m_fields_defined |= FONT_CHARSET_BIT;
        if (pitch()       != file.rendition().font().pitch())
            ((WT_Font &)(*this)).m_fields_defined |= FONT_PITCH_BIT;
        if (family()      != file.rendition().font().family())
            ((WT_Font &)(*this)).m_fields_defined |= FONT_FAMILY_BIT;
        if (style()       != file.rendition().font().style())
            ((WT_Font &)(*this)).m_fields_defined |= FONT_STYLE_BIT;
        if (height()      != file.rendition().font().height())
            ((WT_Font &)(*this)).m_fields_defined |= FONT_HEIGHT_BIT;
        if (width_scale() != file.rendition().font().width_scale())
            ((WT_Font &)(*this)).m_fields_defined |= FONT_WIDTH_SCALE_BIT;
        if (spacing()     != file.rendition().font().spacing())
            ((WT_Font &)(*this)).m_fields_defined |= FONT_SPACING_BIT;
        if (oblique()     != file.rendition().font().oblique())
            ((WT_Font &)(*this)).m_fields_defined |= FONT_OBLIQUE_BIT;
        if (flags()       != file.rendition().font().flags())
            ((WT_Font &)(*this)).m_fields_defined |= FONT_FLAGS_BIT;
        if (rotation()    != file.rendition().font().rotation())
            ((WT_Font &)(*this)).m_fields_defined |= FONT_ROTATION_BIT;

        WD_CHECK (serialize(file));
        file.rendition().font() = *this;
    }
    return WT_Result::Success;
}
Ejemplo n.º 6
0
void DirectoryAdder::slotEntries(KIO::Job *, const KIO::UDSEntryList &entries)
{
	QMap<QString,KURL> __list; // temp list to sort entries

	KIO::UDSEntryListConstIterator it = entries.begin();
	KIO::UDSEntryListConstIterator end = entries.end();

	for (; it != end; ++it)
	{
		KFileItem file(*it, currentJobURL, false /* no mimetype detection */, true);
		// "prudhomm:
		// insert the path + url in the map to sort automatically by path
		// note also that you use audiocd to rip your CDs then it will be sorted the right way
		// now it is an easy fix to have a nice sort BUT it is not the best
		// we should sort based on the tracknumber"
		// - copied over from old kdirlister hack <*****@*****.**>
		__list.insert(file.url().path(), file.url());
	}
	QMap<QString,KURL>::Iterator __it;
	for( __it = __list.begin(); __it != __list.end(); ++__it )
	{
		oblique()->addFile(__it.data(), false);
	}
}
Ejemplo n.º 7
0
double delta(int jd) {
  double sdelta = sin(oblique(jd)) * sin(Lambda(jd));
  return atan(sdelta / sqrt(1.0 - sdelta * sdelta));
}
Ejemplo n.º 8
0
Archivo: font.cpp Proyecto: asir6/Colt
WT_Result WT_Font::serialize(WT_File & file) const
{
    WD_CHECK (file.dump_delayed_drawable());

    file.desired_rendition().blockref();
    WD_CHECK(file.desired_rendition().sync(file, WT_Rendition::BlockRef_Bit));

    file.desired_rendition().font_extension();
    WD_CHECK(file.desired_rendition().sync(file, WT_Rendition::Font_Extension_Bit));

    // BPM: this could be improved when time allows...
    if(file.heuristics().apply_transform() && !m_rotation_checked && file.heuristics().transform().rotation())
    {
        // The first time we start up the file, if the application wants an unrotated
        // font, and we need to flip landscape to portrait, then the above test will think
        // that the rotation doesn't need to be output the first time.  Here we force it...
        ((WT_Font &)(*this)).m_fields_defined |= FONT_ROTATION_BIT;
        ((WT_Font *)this)->m_rotation_checked = WD_True;  // Cast from const to alterable.
    }

    if (file.heuristics().allow_binary_data())
    {
        // Binary
        WD_CHECK (file.write((WT_Byte) 0x06));  // CTRL-F
        WD_CHECK (file.write(m_fields_defined));
    }
    else
    {
        // ASCII Output
        WD_CHECK (file.write_tab_level());
        WD_CHECK (file.write("(Font"));
    }

    if (m_fields_defined & FONT_NAME_BIT)
        WD_CHECK (font_name().serialize(*this, file));
    if (m_fields_defined & FONT_CHARSET_BIT)
        WD_CHECK (charset().serialize(*this, file));
    if (m_fields_defined & FONT_PITCH_BIT)
        WD_CHECK (pitch().serialize(*this, file));
    if (m_fields_defined & FONT_FAMILY_BIT)
        WD_CHECK (family().serialize(*this, file));
    if (m_fields_defined & (FONT_STYLE_BIT))
        WD_CHECK (style().serialize(*this, file));
    if (m_fields_defined & FONT_HEIGHT_BIT)
        WD_CHECK (height().serialize(*this,file));
    if (m_fields_defined & FONT_ROTATION_BIT)
        WD_CHECK (rotation().serialize(*this,file));
    if (m_fields_defined & FONT_WIDTH_SCALE_BIT)
        WD_CHECK (width_scale().serialize(*this,file));
    if (m_fields_defined & FONT_SPACING_BIT)
        WD_CHECK (spacing().serialize(*this,file));
    if (m_fields_defined & FONT_OBLIQUE_BIT)
        WD_CHECK (oblique().serialize(*this,file));
    if (m_fields_defined & FONT_FLAGS_BIT)
        WD_CHECK (flags().serialize(*this,file));

    if (!file.heuristics().allow_binary_data())
        WD_CHECK (file.write((WT_Byte)')'));

    return WT_Result::Success;
}
/**
 * Function that listens for event input from keyboard.
 */
void Keyboard(unsigned char key, int x, int y) {

	switch (key){

	/*projection commands*/
	case '1':
		printf("changing projection to orthographic.\n");
		orthographic();
		break;
	case '2':
		printf("changing projection to oblique.\n");
		oblique();
		break;
	case '3':
		printf("changing projection to perspective.\n");
		perspective();
		break;

	/*camera movement*/

	case 'm':
		printf("Camera movement. You can no use w,a,s,d,z,x to move ");
		printf("around.\n");
		currentMode = 'm';
		glutPostRedisplay();
		break;

	case 'w':
		if(useSmooth == true){
			useSmooth = false;
			bezSpeed += 0.25;
			calculateNewBezierCurve(direction,P0,Pref,V0,bezierP,PrefChange,uM,
									uMPrim,bezSpeed);
			bezierPCounter = 0;
			useSmooth = true;
		}else{
			cameraForward(0);
		}
		break;
	case 'a':
		if(useSmooth == true){
			direction = 'l';
			calculateNewBezierCurve(direction,P0,Pref,V0,bezierP,PrefChange,uM,
									uMPrim,bezSpeed);
			bezierPCounter = 0;
		}else{
			cameraLeft();
		}
		break;
	case 's':
		if(useSmooth == true){
			if(bezSpeed > 0.5){
				useSmooth = false;
				bezSpeed -= 0.25;
				calculateNewBezierCurve(direction,P0,Pref,V0,bezierP,PrefChange,
										uM,uMPrim,bezSpeed);
				bezierPCounter = 0;
				useSmooth = true;
			}

		}else{
			cameraBackward();
		}
		break;
	case 'd':
		if(useSmooth == true){
			direction = 'r';
			calculateNewBezierCurve(direction,P0,Pref,V0,bezierP,PrefChange,uM,
									uMPrim,bezSpeed);
			bezierPCounter = 0;
		}else{
			cameraRight();
		}
		break;

	/*object movement*/
	case 'q':
		printf("Closing program.....\n");
		exit(0);
		break;

	case 'v':
		glutFullScreenToggle();
		break;

	case 'o':
		printf("\ncurrent mode: open OFF file.\n");
		currentMode = 'o';
		glutPostRedisplay();
		loadVertices(NULL);
		glutPostRedisplay();
		break;

	case 't':
		printf("current mode: translation.\n");
		currentMode = 't';
		chosenMovement = 'n';
		chosenMovement = 'n';
		glutPostRedisplay();
		printf("In which direction (x,y or z) do you want to move the object?");
		printf("\npress x,y or z button to choose.\n");

		break;

	case 'e':
		printf("current mode: Scaling.\n");
		currentMode = 's';
		glutPostRedisplay();
		chosenMovement = 'n';
		chosenMovement = 'n';
		printf("press + or - button to scale the object.\n");
		break;

	case 'r':
		printf("current mode: Rotating.\n");
		currentMode = 'r';
		glutPostRedisplay();
		chosenMovement = 'n';
		chosenMovement = 'n';
		printf("Press x,y,or z to choose which axis the object should ");
		printf("rotate around.\n");
		break;

	case 'x':

		if(currentMode == 't'){
			printf("X direction chosen. press + or - button ");
			printf("to move the object.\n");
			chosenDirection = 'x';
		}else if(currentMode == 'r'){
			printf("X direction chosen. press + or - button ");
			printf("to rotate the object around the X-axis.\n");
			chosenDirection = 'x';
		}else{
			cameraUp();
		}
		break;

	case 'y':
		if(currentMode == 't'){
			printf("Y direction chosen. press + or - button ");
			printf("to move the object.\n");
			chosenDirection = 'y';
		}else if(currentMode == 'r'){
			printf("Y direction chosen. press + or - button ");
			printf("to rotate the object around the Y-axis.\n");
			chosenDirection = 'y';
		}
		break;

	case 'z':
		if(currentMode == 't'){
			printf("Z direction chosen. press + or - button ");
			printf("to move the object.\n");
			chosenDirection = 'z';
		} else if(currentMode == 'r'){
			printf("Z direction chosen. press + or - button ");
			printf("to rotate the object around the Z-axis.\n");
			chosenDirection = 'z';
		}else{
			cameraDown();
		}
	break;

	case '+':

		if(currentMode == 't'){
			if(chosenDirection == 'x' || chosenDirection == 'y'
					|| chosenDirection == 'z'){
				chosenMovement = '+';
				translateStage();
			}
		}else if(currentMode == 's'){
			chosenMovement = '+';
			scaleStage();
		}else if(currentMode == 'r'){
			chosenMovement = '+';
			rotateStage();
		}

		break;

	case '-':
		if(currentMode == 't'){
			if(chosenDirection == 'x' || chosenDirection == 'y'
					|| chosenDirection == 'z'){
				chosenMovement = '-';
				translateStage();
			}
		}else if(currentMode == 's'){
			chosenMovement = '-';
			scaleStage();
		}else if(currentMode == 'r'){
			chosenMovement = '-';
			rotateStage();
		}

		break;

	case 'f':
		/*changes between line mode and filled mode for the object.*/
		if(objectFilled == false){
			glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
			sendTMatrixToGPU();
			glutPostRedisplay();
			objectFilled = true;
		}else if(objectFilled == true){
			glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
			sendTMatrixToGPU();
			glutPostRedisplay();
			objectFilled = false;
		}
		break;

	case 'h':

		printf("Help:\n----------------------------------------------------\n");
		printf("The allowed keyboard commands are: \n");
		printf("o: open file,		q: quit program,	t: transform object\n");
		printf("e: scale object,	r: rotate object,	m: camera movement.\n");
		printf("f: object fill: on/off	");
		printf("x: choose x-axis. If camera mode: go up.\ny: choose y-axis	");
		printf("z: choose z-axis. If camera mode: go down.\n\n");
		printf("w: move camera forward.		a: move camera left.\n");
		printf("s: move camera backwards.	d: move camera right.\n");
		printf("v: toggle between fullscreenmode..\n");
		printf("1: orthographic projection.	2: oblique projection.\n");
		printf("3: perspective projection.\n");
		printf("You may also use the mouse to move the camera. To enable, ");
		printf("press and hold left\nmouse button and move the mouse.\n");
		printf("Use the mouseScroll to zoom in or out.\n");
		printf("-----------------------------------------------------------\n");
		break;

	default:
		printf("Unknown keyboard command. Press \"h\" for help. \n");
		break;
	}
}