Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
pyMKcam
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
pyMKcam
Commits
7259d2f0
Commit
7259d2f0
authored
Oct 29, 2012
by
Lars Kruse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow point comparison for selected axes
parent
6e4610d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
14 deletions
+10
-14
PointUtils.py
pycam/Geometry/PointUtils.py
+10
-14
No files found.
pycam/Geometry/PointUtils.py
View file @
7259d2f0
...
...
@@ -23,8 +23,6 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
from
pycam.Geometry.utils
import
epsilon
,
sqrt
,
number
def
_is_near_float
(
x
,
y
):
return
abs
(
x
-
y
)
<
epsilon
def
pnorm
(
a
):
return
sqrt
(
pdot
(
a
,
a
))
...
...
@@ -40,22 +38,20 @@ def pdist_sq(a, b, axes=None):
axes
=
(
0
,
1
,
2
)
return
sum
([(
a
[
index
]
-
b
[
index
])
**
2
for
index
in
axes
])
def
pnear
(
a
,
b
):
return
_is_near_float
(
a
[
0
],
b
[
0
])
and
_is_near_float
(
a
[
1
],
b
[
1
])
and
\
_is_near_float
(
a
[
2
],
b
[
2
])
def
pnear
(
a
,
b
,
axes
=
None
):
return
pcmp
(
a
,
b
,
axes
=
axes
)
==
0
def
pcmp
(
a
,
b
):
def
pcmp
(
a
,
b
,
axes
=
None
):
""" Two points are equal if all dimensions are identical.
Otherwise the result is based on the individual x/y/z comparisons.
"""
if
pnear
(
a
,
b
):
return
0
elif
not
_is_near
(
a
[
0
],
b
[
0
]):
return
cmp
(
a
[
0
],
b
[
0
])
elif
not
_is_near
(
a
[
1
],
b
[
1
]):
return
cmp
(
a
[
1
],
b
[
1
])
else
:
return
cmp
(
a
[
2
],
b
[
2
])
if
axes
is
None
:
axes
=
(
0
,
1
,
2
)
for
axis
in
axes
:
if
abs
(
a
[
axis
]
-
b
[
axis
])
>
epsilon
:
return
cmp
(
a
[
axis
],
b
[
axis
])
# both points are at the same position
return
0
def
ptransform_by_matrix
(
a
,
matrix
):
if
len
(
a
)
>
3
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment