Skip to content

Commit

Permalink
Draft: WorkingPlane, Pythonic style, added spaces after commas, and r…
Browse files Browse the repository at this point in the history
…emoved trailing whitespace
  • Loading branch information
vocx-fc authored and yorikvanhavre committed Aug 9, 2019
1 parent ba5ba2a commit f54cbb9
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Mod/Draft/WorkingPlane.py
Expand Up @@ -108,7 +108,7 @@ def projectPoint(self, p, direction=None):
gd = self.getGlobalRot(Vector(ld.x, ld.y, 0))
hyp = abs(math.tan(a) * lp.z)
return gp.add(DraftVecUtils.scaleTo(gd, hyp))

def projectPointOld(self, p, direction=None):
'''project point onto plane, default direction is orthogonal. Obsolete'''
if not direction:
Expand Down Expand Up @@ -161,7 +161,7 @@ def alignToPointAndAxis_SVG(self, point, axis, offset):
self.u.normalize()
self.v = DraftVecUtils.rotate(self.u, math.pi/2, self.axis)
#projcase = "Case new"

elif ((abs(axis.y) > abs(axis.z)) and (abs(axis.z) >= abs(axis.x))):
ref_vec = Vector(1.0, 0.0, 0.0)
self.u = axis.negative().cross(ref_vec)
Expand Down Expand Up @@ -198,7 +198,7 @@ def alignToPointAndAxis_SVG(self, point, axis, offset):
#spat_vec = self.u.cross(self.v)
#spat_res = spat_vec.dot(axis)
#FreeCAD.Console.PrintMessage(projcase + " spat Prod = " + str(spat_res) + "\n")

offsetVector = Vector(axis); offsetVector.multiply(offset)
self.position = point.add(offsetVector)
self.weak = False
Expand Down Expand Up @@ -252,7 +252,7 @@ def alignToFace(self, shape, offset=0):
self.u, self.v = self.v.negative(), self.u
elif DraftVecUtils.equals(self.u, Vector(0, 0, -1)):
self.u, self.v = self.v, self.u.negative()

self.weak = False
return True
else:
Expand Down Expand Up @@ -358,7 +358,7 @@ def setFromPlacement(self, pl, rebase=False):
self.axis = rot.multVec(FreeCAD.Vector(0, 0, 1))
if rebase:
self.position = pl.Base

def inverse(self):
"inverts the direction of the working plane"
self.u = self.u.negative()
Expand Down Expand Up @@ -426,7 +426,7 @@ def getGlobalRot(self, point):
vz = Vector(self.axis).multiply(point.z)
pt = (vx.add(vy)).add(vz)
return pt

def getClosestAxis(self, point):
"returns which of the workingplane axes is closest from the given vector"
ax = point.getAngle(self.u)
Expand All @@ -444,7 +444,7 @@ def getClosestAxis(self, point):
return "z"
else:
return None

def isGlobal(self):
"returns True if the plane axes are equal to the global axes"
if self.u != Vector(1, 0, 0):
Expand All @@ -454,15 +454,15 @@ def isGlobal(self):
if self.axis != Vector(0, 0, 1):
return False
return True

def isOrtho(self):
"returns True if the plane axes are following the global axes"
if round(self.u.getAngle(Vector(0, 1, 0)), 6) in [0, -1.570796, 1.570796, -3.141593, 3.141593, -4.712389, 4.712389, 6.283185]:
if round(self.v.getAngle(Vector(0,1,0)),6) in [0, -1.570796, 1.570796, -3.141593, 3.141593, -4.712389, 4.712389, 6.283185]:
if round(self.axis.getAngle(Vector(0,1,0)),6) in [0, -1.570796, 1.570796, -3.141593, 3.141593, -4.712389, 4.712389, 6.283185]:
if round(self.v.getAngle(Vector(0, 1, 0)), 6) in [0, -1.570796, 1.570796, -3.141593, 3.141593, -4.712389, 4.712389, 6.283185]:
if round(self.axis.getAngle(Vector(0, 1, 0)), 6) in [0, -1.570796, 1.570796, -3.141593, 3.141593, -4.712389, 4.712389, 6.283185]:
return True
return False

def getDeviation(self):
"returns the deviation angle between the u axis and the horizontal plane"
proj = Vector(self.u.x, self.u.y, 0)
Expand All @@ -471,7 +471,7 @@ def getDeviation(self):
else:
norm = proj.cross(self.u)
return DraftVecUtils.angle(self.u, proj, norm)

def getPlacementFromPoints(points):
"returns a placement from a list of 3 or 4 vectors"
pl = plane()
Expand All @@ -488,7 +488,7 @@ def getPlacementFromPoints(points):
p = pl.getPlacement()
del pl
return p

def getPlacementFromFace(face, rotated=False):
"returns a placement from a face"
pl = plane()
Expand Down

0 comments on commit f54cbb9

Please sign in to comment.