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)
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)
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)
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
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)
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
def tostr(val): return str(round(val, DraftVecUtils.precision()))
def tostr(val): return str(round(val,DraftVecUtils.precision()))