Esempio n. 1
0
 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
Esempio n. 2
0
 def distanceLinePlane(self, line: Line, plane: Plane):
     if plane.getType() == "normal" or plane.getType() == "coordinate":
         normVec = plane.getNormalVector()
         if normVec.scalarProduct(line.getDirectionVector()) == 0:
             distance = Solvers.distancePlanePoint(line.getPositionVector(),
                                                   plane)
         else:
             distance = 0
         return distance
     else:
         normVec = plane.getDirectionVectorOne().vectorProduct(
             plane.getDirectionVectorTwo())
         if normVec.scalarProduct(line.getDirectionVector()) == 0:
             distance = Solvers.distancePlanePoint(line.getPositionVector(),
                                                   plane)
         else:
             distance = 0
         return distance
Esempio n. 3
0
 def distanceLineLine(self, line1: Line, line2: Line):
     if Solvers.checkLinearAbhaengig(line1.getDirectionVector(),
                                     line2.getDirectionVector()) == True:
         if Solvers.checkPointInLine(line1,
                                     line2.getPositionVector()) == True:
             print("Identisch")
         else:
             distance = Solvers.distancePointLine(line2.getPositionVector(),
                                                  line1)
     elif Solvers.schnittpunkt(line1, line2) is not None:
         distance = 0
     else:
         normVec = line1.getDirectionVector().vectorProduct(
             line2.getDirectionVector())
         scalarParam = normVec.scalarProduct(line1.getPositionVector())
         helpPlane = Plane.coordinateForm(normVec, scalarParam)
         distance = Solvers.distancePlanePoint(line2.getPositionVector(),
                                               helpPlane)
     return distance
Esempio n. 4
0
    def schnittpunkt(self, line1: Line, line2: Line):
        """Returns the Schnittpunkt between two Lines.
           Uses Solvers.solveForSchnittstelle.
           Returns a Point instance."""

        posVec1 = line1.getPositionVector()
        posVec2 = line2.getPositionVector()
        dirVec1 = line1.getDirectionVector()
        dirVec2 = line2.getDirectionVector()
        schnittstelle = self.solveForSchnittstelle(line1, line2)

        ValOne = posVec1.add(dirVec1.scalarMultiplication(schnittstelle[0]))
        ValTwo = posVec2.add(dirVec2.scalarMultiplication(schnittstelle[0]))
        if ValOne.getX() == ValTwo.getX() and ValOne.getY() == ValTwo.getY(
        ) and ValOne.getZ() == ValTwo.getZ():
            schnittpunkt = ValOne
        else:
            schnittpunkt = None
        return schnittpunkt