Exemple #1
0
def isFigureConvex(figure):
	if not isFigureClosed(figure):
		return False
	innerPoint=algebra.vectAvg(*(v.position for v in figure if v.dim==0))
	facetsInnerPoints=dict()
	edgesParents=dict()
	for facet in figure.boundary:
		facetsInnerPoints[facet]=algebra.vectAvg(*(v.position for v in facet if v.dim==0))
		for edge in facet.boundary:
			if not edge in edgesParents:
				edgesParents[edge]=set()
			edgesParents[edge].add(facet)
	hyperplanes=spaceCuts.hyperplanesOfFigure(figure);
	for facet in figure.boundary:
		hyperplane=spaceCuts.hyperplaneOfFacet(facet, innerPoint)
		for edge in facet.boundary:
			facet2=[f for f in edgesParents[edge] if f!=facet][0]
			point=facetsInnerPoints[facet2]
			if hyperplane.orientedDistance(point)<0.0001:
				return False
	return True
def isFigureConvex(figure):
	if not isBoundaryComplete(figure):
		return False
	innerPoint=algebra.vectAvg(*(v.position for v in figure if v.dim==0))
	facetsInnerPoints=dict()
	edgesParents=dict()
	for facet in figure.boundary:
		facetsInnerPoints[facet]=algebra.vectAvg(*(v.position for v in facet if v.dim==0))
		for edge in facet.boundary:
			if not edge in edgesParents:
				edgesParents[edge]=set()
			edgesParents[edge].add(facet)
	hyperplanes=spaceCuts.hyperplanesOfFigure(figure);
	for facet in figure.boundary:
		hyperplane=spaceCuts.hyperplaneOfFacet(facet, innerPoint)
		for edge in facet.boundary:
			facet2=[f for f in edgesParents[edge] if f!=facet][0]
			point=facetsInnerPoints[facet2]
			if hyperplane.orientedDistance(point)<0.0001:
				return False
	return True
Exemple #3
0
def cutOffConvex(figure, hyperplanes, innerPoint=None):
	hyperplanes=hyperplanes+spaceCuts.hyperplanesOfFigure(figure)
	return [spaceCuts.figureFromArea(hyperplanes, innerPoint)]