Skip to content

Commit

Permalink
Draft: WorkingPlane, Pythonic style, improved the docstring; why does…
Browse files Browse the repository at this point in the history
… the projection invert the direction of the component, that is, -x instead of x, if the angle between the vectors x and u is larger than 1 radian? Why specifically 1 radian?
  • Loading branch information
vocx-fc authored and yorikvanhavre committed Aug 9, 2019
1 parent ad74402 commit 023cf12
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Mod/Draft/WorkingPlane.py
Expand Up @@ -828,10 +828,28 @@ def restore(self):
self.stored = None

def getLocalCoords(self, point):
"returns the coordinates of a given point on the working plane"
"""Return the coordinates of a given point projected on the plane.
A vector is calculated from the plane's `position`
to the external `point`, and this vector is projected into
each of the `u`, `v` and `axis` of the plane.
Parameters
----------
point : Base::Vector3
The point external to the plane.
Returns
-------
Base::Vector3
The point projected on the plane.
"""
pt = point.sub(self.position)
xv = DraftVecUtils.project(pt, self.u)
x = xv.Length
# If the angle between the projection xv and u
# is larger than 1 radian (57.29 degrees), use the negative
# of the magnitude. Why exactly 1 radian?
if xv.getAngle(self.u) > 1:
x = -x
yv = DraftVecUtils.project(pt, self.v)
Expand Down

0 comments on commit 023cf12

Please sign in to comment.