view transform.c @ 4:8d0ee5ea10ac

Linear transforms program
author jsipek@huey.fsl.cs.sunysb.edu
date Thu, 24 Nov 2005 00:34:19 -0400
parents
children 02aee7371541
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]);

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


	return 0;
}