demos/vector.py
author Radek Brich <radek.brich@devl.cz>
Tue, 06 May 2008 09:39:58 +0200
branchpyrit
changeset 93 96d65f841791
parent 72 7c3f38dff082
permissions -rw-r--r--
more build script tuning make all float constants single precision solve many warnings from msvc and gcc with various -W... flags add common.cc file for dbgmsg() function witch apparently cannot be inlined fix python module building with msvc, add manifest file handling remove forgotten RenderrowData class add stanford models download script for windows (.bat)

from math import *

def dot(a,b):
	sum = 0
	for i in range(min(len(a),len(b))):
		sum += a[i]*b[i]
	return sum

def cross(a,b):
	return (
		a[1]*b[2] - a[2]*b[1],
		a[2]*b[0] - a[0]*b[2],
		a[0]*b[1] - a[1]*b[0]
	)

def unit(a):
	m = mag(a)
	return (a[0]/m, a[1]/m, a[2]/m)

def mag(a):
	return sqrt(mag2(a))

def mag2(a):
	return a[0]*a[0] + a[1]*a[1] + a[2]*a[2]