view transform.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 cc1adef5674e
line wrap: on
line source

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

void transform(float trans[3][3], float pt[3], float colors[3])
	printf("%f %f %f %f %f %f\n", colors[0], colors[1], colors[2],
			     (trans[0][0]*pt[0] + trans[0][1]*pt[1] + trans[0][2]*pt[2]),
			     (trans[1][0]*pt[0] + trans[1][1]*pt[1] + trans[1][2]*pt[2]),
			     (trans[2][0]*pt[0] + trans[2][1]*pt[1] + trans[2][2]*pt[2]));

int main(int argc, char** argv)
	float trans[3][3];
	float pt[3]; // coords
	float c[3]; // colors

	scanf("%f %f %f", &trans[0][0], &trans[0][1], &trans[0][2]);
	scanf("%f %f %f", &trans[1][0], &trans[1][1], &trans[1][2]);
	scanf("%f %f %f", &trans[2][0], &trans[2][1], &trans[2][2]);

	while(scanf("%f %f %f %f %f %f", &c[0], &c[1], &c[2], &pt[0], &pt[1], &pt[2]) == 6)
		transform(trans, pt, c);

	return 0;