From 023cf12c507f1a2cf2852261ff050aa2f11f608e Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Thu, 8 Aug 2019 17:05:22 -0500 Subject: [PATCH] Draft: WorkingPlane, Pythonic style, improved the docstring; why does 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? --- src/Mod/Draft/WorkingPlane.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Mod/Draft/WorkingPlane.py b/src/Mod/Draft/WorkingPlane.py index f67133e908..e58d999b60 100644 --- a/src/Mod/Draft/WorkingPlane.py +++ b/src/Mod/Draft/WorkingPlane.py @@ -828,10 +828,28 @@ class plane: 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)