changeset 4:8d0ee5ea10ac

Linear transforms program
author jsipek@huey.fsl.cs.sunysb.edu
date Thu, 24 Nov 2005 00:34:19 -0400
parents 07bd1f7e38f7
children 02aee7371541
files .hgignore Makefile transform.c transtest
diffstat 4 files changed, 43 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Thu Nov 24 00:13:01 2005 -0400
+++ b/.hgignore	Thu Nov 24 00:34:19 2005 -0400
@@ -1,2 +1,3 @@
 \.swp$
 ^render$
+^transform$
--- a/Makefile	Thu Nov 24 00:13:01 2005 -0400
+++ b/Makefile	Thu Nov 24 00:34:19 2005 -0400
@@ -1,5 +1,10 @@
-all:
+all: render transform
+
+render: render.c
 	gcc render.c -o render -I/usr/X11R6/include/ -L/usr/X11R6/lib -lX11 -lXi -lXmu -lglut -lGL -lGLU -g -Wall
 
+transform: transform.c
+	gcc -o transform transform.c -Wall -g
+
 clean:
-	rm -f render *~ *.o a.out
+	rm -f render transform *~ *.o a.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/transform.c	Thu Nov 24 00:34:19 2005 -0400
@@ -0,0 +1,30 @@
+#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;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/transtest	Thu Nov 24 00:34:19 2005 -0400
@@ -0,0 +1,5 @@
+0.866 -0.5 0
+0.5 0.866 0
+0 0 1
+1 0 0 5 2 4
+