view normalize.c @ 20:ebc55ce699ec

Rotate the other way around: z, y, x - more useful to us
author Josef "Jeff" Sipek <jeffpc@optonline.net>
date Sat, 03 Dec 2005 00:35:58 -0500
parents 5ac8c7980aaf
children cc1adef5674e
line wrap: on
line source

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

void normalize(float pt[3])
{
	float mag = sqrt(pt[0]*pt[0] + pt[1]*pt[1] + pt[2]*pt[2]);
	if (mag == 0) {
		printf("0 0 0\n");
		return;
	}
	printf("%f %f %f\n", pt[0] / mag, pt[1] / mag, pt[2] / mag);
}

int main(int argc, char **argv) 
{
	float pt[3];
	
	while(scanf("%*f %*f %*f %f %f %f", &pt[0], &pt[1], &pt[2])==3)
		normalize(pt);
	
	return 0;
}