Skip to content

Commit

Permalink
Draft: Allow to define rounding value in DraftVecUtils.rounded
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jun 11, 2020
1 parent 11a2b94 commit 415b0dc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Mod/Draft/DraftVecUtils.py
Expand Up @@ -703,8 +703,9 @@ def isColinear(vlist):
return True


def rounded(v):
"""Return a vector rounded to the `precision` in the parameter database.
def rounded(v,d=None):
"""Return a vector rounded to the `precision` in the parameter database
or to the given decimals value
Each of the components of the vector is rounded to the decimal
precision set in the parameter database.
Expand All @@ -713,6 +714,7 @@ def rounded(v):
----------
v : Base::Vector3
The input vector.
d : (Optional) the number of decimals to round to
Returns
-------
Expand All @@ -722,6 +724,8 @@ def rounded(v):
in the parameter database.
"""
p = precision()
if d:
p = d
return Vector(round(v.x, p), round(v.y, p), round(v.z, p))


Expand Down

1 comment on commit 415b0dc

@vocx-fc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I noticed that in DraftGeomUtils there is a slightly different version of precision. I think we should homologize it, and use a global precision for everything. Because it seems that DraftGeomUtils uses one precision, and the rest of Draft uses a precision defined in draftutils.utils. They both use the parameter database, but still it's not the same function; we really should avoid that.

Please sign in to comment.