view rotate.c @ 13:51e9b6b85edd

Fixed up rotation, now supports arbitrary rotation around, x, y, and z (in that order)
author Josef "Jeff" Sipek <>
date Fri, 02 Dec 2005 23:04:10 -0500
parents 02aee7371541
children ebc55ce699ec
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

void rotate_header(float omega, float phi, float rho)
	printf("%f %f %f\n"
	       "%f %f %f\n"
	       "%f %f %f", cos(phi)*cos(rho), cos(rho)*sin(omega)*sin(phi)-cos(omega)*sin(rho), cos(omega)*cos(rho)*sin(phi)+sin(omega)*sin(rho),
	       		   cos(phi)*sin(rho), cos(omega)*cos(rho)+sin(omega)*sin(phi)*sin(rho), -cos(rho)*sin(omega)+cos(omega)*sin(phi)*sin(rho),
			   -sin(phi), cos(phi)*sin(omega), cos(omega)*cos(phi));

int main(int argc, char** argv)
	float omega, phi, rho;
	char c;

	scanf("%f %f %f", &omega, &phi, &rho);
	rotate_header(omega, phi, rho);

	while((c = getc(stdin)) != EOF)
		putc(c, stdout);

	return 0;