Ejemplo n.º 1
0
    def projectPointOld(self, p, direction=None):
        """Project a point onto the plane. OBSOLETE.

        Parameters
        ----------
        p : Base::Vector3
            The point to project.
        direction : Base::Vector3, optional
            The unit vector that indicates the direction of projection.

            It defaults to `None`, which then uses the `plane.axis` (normal)
            value, meaning that the point is projected perpendicularly
            to the plane.

        Returns
        -------
        Base::Vector3
            The projected point,
            or the original point if the angle between the `direction`
            and the `plane.axis` is 90 degrees.
        """
        if not direction:
            direction = self.axis
        t = Vector(direction)
        # t.normalize()
        a = round(t.getAngle(self.axis), DraftVecUtils.precision())
        pp = round((math.pi)/2, DraftVecUtils.precision())
        if a == pp:
            return p
        t.multiply(self.offsetToPoint(p, direction))
        return p.add(t)
Ejemplo n.º 2
0
 def projectPointOld(self, p, direction=None):
     '''project point onto plane, default direction is orthogonal. Obsolete'''
     if not direction:
         direction = self.axis
     t = Vector(direction)
     #t.normalize()
     a = round(t.getAngle(self.axis), DraftVecUtils.precision())
     pp = round((math.pi) / 2, DraftVecUtils.precision())
     if a == pp:
         return p
     t.multiply(self.offsetToPoint(p, direction))
     return p.add(t)
Ejemplo n.º 3
0
 def projectPointOld(self, p, direction=None):
     '''project point onto plane, default direction is orthogonal. Obsolete'''
     if not direction:
         direction = self.axis
     t = Vector(direction)
     #t.normalize()
     a = round(t.getAngle(self.axis),DraftVecUtils.precision())
     pp = round((math.pi)/2,DraftVecUtils.precision())
     if a == pp:
         return p
     t.multiply(self.offsetToPoint(p, direction))
     return p.add(t)
Ejemplo n.º 4
0
    def correctlyOriented(self, planeNormal):
        if not self.originalFace:
            return True

        faceNormal = self.originalFace.normalAt(0, 0)
        angle = math.degrees(faceNormal.getAngle(planeNormal))
        angle = round(angle, DraftVecUtils.precision())

        return angle != 90
Ejemplo n.º 5
0
def toNumberString(val, precision=None):
    if precision is None:
        precision = DraftVecUtils.precision()

    rounded = round(val, precision)

    if precision == 0:
        rounded = int(rounded)

    return str(rounded)
Ejemplo n.º 6
0
def isEdgeOnPlane(edge, plane):
    precision = DraftVecUtils.precision()
    planeBase = plane.CenterOfMass
    planeNormal = plane.normalAt(0.5, 0.5)

    points = [v.Point for v in edge.Vertexes]

    for p in points:
        distance = p.distanceToPlane(planeBase, planeNormal)

        if distance < 0:
            distance = distance * -1

        if distance > precision:
            return False

    return True
Ejemplo n.º 7
0
 def tostr(val):
     return str(round(val, DraftVecUtils.precision()))
Ejemplo n.º 8
0
 def tostr(val):
     return str(round(val,DraftVecUtils.precision()))