3d-dart/server/system/NAfunctionLib.py
def rmatrixz(vec):
	
	"""Return a rotation matrix which transforms the coordinate system such that the vector vec is aligned along the z axis."""
	u, v, w = normalize(vec)

	d = math.sqrt(u*u + v*v)

	if d != 0.0:
            Rxz = array([ [  u/d, v/d,  0.0 ],
                       	[ -v/d, u/d,  0.0 ],
                       	[  0.0, 0.0,  1.0 ] ], float)
	else:
            Rxz = numpy.identity(3, float)

	Rxz2z = array([ [   w, 0.0,    -d],
                        [ 0.0, 1.0,   0.0],
                        [   d, 0.0,     w] ], float)

	R = matrixmultiply(Rxz2z, Rxz)

	try:
            assert numpy.allclose(numpy.linalg.determinant(R), 1.0)
	except AssertionError:
            print "rmatrixz(%s) determinant(R)=%f" % (vec, numpy.linalg.determinant(R))
            raise

	return R
Return a rotation matrix which transforms the coordinate system such that the vector vec is aligned along the z axis.
Return a rotation matrix which transforms the coordinate system such that the vector vec is aligned along the z axis.
Return a rotation matrix which transforms the coordinate system such that the vector vec is aligned along the z axis .
def rmatrixz(vec):
	u, v, w = normalize(vec)
	d = math.sqrt(u*u + v*v)
	if d != 0.0:
            Rxz = array([ [  u/d, v/d,  0.0 ],
                       	[ -v/d, u/d,  0.0 ],
                       	[  0.0, 0.0,  1.0 ] ], float)
	else:
            Rxz = numpy.identity(3, float)
	Rxz2z = array([ [   w, 0.0,    -d],
                        [ 0.0, 1.0,   0.0],
                        [   d, 0.0,     w] ], float)
	R = matrixmultiply(Rxz2z, Rxz)
	try:
            assert numpy.allclose(numpy.linalg.determinant(R), 1.0)
	except AssertionError:
            print "rmatrixz(%s) determinant(R)=%f" % (vec, numpy.linalg.determinant(R))
            raise
	return R
def rmatrixz ( vec ) : u , v , w = normalize ( vec ) d = math . sqrt ( u * u + v * v ) if d != 0.0 : Rxz = array ( [ [ u / d , v / d , 0.0 ] , [ - v / d , u / d , 0.0 ] , [ 0.0 , 0.0 , 1.0 ] ] , float ) else : Rxz = numpy . identity ( 3 , float ) Rxz2z = array ( [ [ w , 0.0 , - d ] , [ 0.0 , 1.0 , 0.0 ] , [ d , 0.0 , w ] ] , float ) R = matrixmultiply ( Rxz2z , Rxz ) try : assert numpy . allclose ( numpy . linalg . determinant ( R ) , 1.0 ) except AssertionError : print "rmatrixz(%s) determinant(R)=%f" % ( vec , numpy . linalg . determinant ( R ) ) raise return R
Return a rotation matrix which transforms the coordinate system such that the vector vec is aligned along the z axis.
Return a rotation matrix which transforms the coordinate system such that the vector vec is aligned along the z axis .
"""Return a rotation matrix which transforms the coordinate system such that the vector vec is aligned along the z axis."""
vec