示例#1
0
def createDual(figure, centerPoint=None):
	if figure.dim<2:
		raise RuntimeError("Figure has to have at least 2 dimensions")
	dualFigure=Figure()
	objFigure.updateVerticesLists(figure)
	for f in figure:
		f.dualCache=None
	try:
		for f in figure:
			d=figure.dim-f.dim-1
			if d<0: continue
			if d==0: # create vertex of the dual figure using polar reciprocation
				vertsPos=[v.position for v in f.vertices]
				hyperplane=algebra.hyperplaneFromPoints(vertsPos)
				f.dualCache=Vertex(dualPointFromHyperplane(hyperplane, centerPoint))
			else:
				f.dualCache=Figure()
				f.dualCache.setDim(d,figure.spaceDim)
			f.dualCache.origDualFace=f
		for f in figure:
			if f.dim<figure.dim:
				for child in f.boundary:
					child.dualCache.addToBoundary(f.dualCache)
				if f.dim == 0:
					dualFigure.addToBoundary(f.dualCache)
	finally:
		for f in figure:
			del f.dualCache
	return dualFigure
示例#2
0
def createDual(figure, centerPoint=None):
	if figure.dim<2:
		raise RuntimeError("Figure has to have at least 2 dimensions")
	figureElem = sorted(figure, key=attrgetter('dim'), reverse=True)[1:]
	dualFigure=Figure()
	for f in figureElem:
		f.dualCache=None
	try:
		for f in figureElem:
			if not f.dualCache: # create vertex of the dual figure using polar reciprocation
				vertsPos=[v.position for v in f if v.dim==0]
				hyperplane=algebra.hyperplaneFromPoints(vertsPos)
				f.dualCache=Vertex(dualPointFromHyperplane(hyperplane, centerPoint))
			for child in f.boundary:
				if not child.dualCache:
					child.dualCache=Figure()
				child.dualCache.addToBoundary(f.dualCache)
				if child.dim == 0:
					dualFigure.addToBoundary(child.dualCache)
	finally:
		for f in figureElem:
			del f.dualCache
	return dualFigure
def hyperplaneOfFacet(facet, positivePoint=None):
    vertsPos = [v.position for v in facet if v.dim == 0]
    return algebra.hyperplaneFromPoints(vertsPos, positivePoint)
def hyperplaneOfFacet(facet, positivePoint=None):
	vertsPos=[v.position for v in facet if v.dim==0]
	return algebra.hyperplaneFromPoints(vertsPos, positivePoint)