def checkPointInPlane(self, plane: Plane, point: Point): vector = Vector3D(point.getX(), point.getY(), point.getZ()) typeOfPlane = plane.getType() pointInPlane = False if typeOfPlane == "normal": result = vector.subtract(plane.getPositionVector()) answer = result.scalarProduct(plane.getNormalVector()) if answer == 0: pointInPlane = True else: pointInPlane = False elif typeOfPlane == "parameter": dirVec1 = plane.getDirectionVectorOne() dirVec2 = plane.getDirectionVectorTwo() result = vector.subtract(plane.getPositionVector()) arrayOne = np.array([[dirVec1.getX(), dirVec1.getY()], [dirVec2.getX(), dirVec2.getY()]]) arrayTwo = np.array([result.getX(), result.getY()]) solution = np.linalg.solve(arrayOne, arrayTwo) if solution[0] * dirVec1.getZ() + solution[1] * dirVec2.getZ( ) == result.getZ(): pointInPlane = True else: pointInPlane = False elif typeOfPlane == "coordinate": normVec = plane.getNormalVector() if point.getX() * normVec.getX() + point.getY() * normVec.getY( ) + point.getZ() * normVec.getZ() == plane.getScalarParameter(): pointInPlane = True else: pointInPlane = False return pointInPlane
def solveForPointPlane(self, line: Line, plane: Plane): if plane.getType() == "normal": normVec = plane.getNormalVector() posVecP = plane.getPositionVector() scalarParam = posVecP.scalarProduct(normVec) posVec = line.getPositionVector() dirVec = line.getDirectionVector() xValNoVar = normVec.getX() * posVec.getX() yValNoVar = normVec.getY() * posVec.getY() zValNoVar = normVec.getZ() * posVec.getZ() xValVar = normVec.getX() * dirVec.getX() yValVar = normVec.getY() * dirVec.getY() zValVar = normVec.getZ() * dirVec.getZ() ValVar = xValVar + yValVar + zValVar ValNoVar = scalarParam - xValNoVar - yValNoVar - zValNoVar Var = ValNoVar / ValVar SchnittPoint = Point(posVec.getX() + Var * dirVec.getX(), posVec.getY() + Var * dirVec.getY(), posVec.getZ() + Var * dirVec.getZ()) return SchnittPoint elif plane.getType() == "coordinate": normVec = plane.getNormalVector() scalarParam = plane.getScalarParameter() posVec = line.getPositionVector() dirVec = line.getDirectionVector() xValNoVar = normVec.getX() * posVec.getX() yValNoVar = normVec.getY() * posVec.getY() zValNoVar = normVec.getZ() * posVec.getZ() xValVar = normVec.getX() * dirVec.getX() yValVar = normVec.getY() * dirVec.getY() zValVar = normVec.getZ() * dirVec.getZ() ValVar = xValVar + yValVar + zValVar ValNoVar = scalarParam - xValNoVar - yValNoVar - zValNoVar Var = ValNoVar / ValVar SchnittPoint = Point(posVec.getX() + Var * dirVec.getX(), posVec.getY() + Var * dirVec.getY(), posVec.getZ() + Var * dirVec.getZ()) return SchnittPoint elif plane.getType() == "parameter": normVec = plane.getDirectionVectorOne().vectorProduct( plane.getDirectionVectorTwo()) posVecP = plane.getPositionVector() scalarParam = posVecP.scalarProduct(normVec) posVec = line.getPositionVector() dirVec = line.getDirectionVector() xValNoVar = normVec.getX() * posVec.getX() yValNoVar = normVec.getY() * posVec.getY() zValNoVar = normVec.getZ() * posVec.getZ() xValVar = normVec.getX() * dirVec.getX() yValVar = normVec.getY() * dirVec.getY() zValVar = normVec.getZ() * dirVec.getZ() ValVar = xValVar + yValVar + zValVar ValNoVar = scalarParam - xValNoVar - yValNoVar - zValNoVar Var = ValNoVar / ValVar SchnittPoint = Point(posVec.getX() + Var * dirVec.getX(), posVec.getY() + Var * dirVec.getY(), posVec.getZ() + Var * dirVec.getZ()) return SchnittPoint