MCPcopy Create free account
hub / github.com/PageBot/PageBot / point3D

Function point3D

Lib/pagebot/toolbox/units.py:58–84  ·  view source on GitHub ↗

Answers `p` as a 3D point. If it is already a list of 3 elements, then don't change and answer the original. If it's a smaller or larger list / tuple, then extend it. >>> point3D() # Default 3D origin (0pt, 0pt, 0pt) >>> point3D(pt(20, -40)) # Add z = pt(0) (20pt, -40pt, 0pt

(p=None)

Source from the content-addressed store, hash-verified

56# P O I N T
57
58def point3D(p=None):
59 """Answers `p` as a 3D point. If it is already a list of 3 elements, then
60 don't change and answer the original. If it's a smaller or larger list /
61 tuple, then extend it.
62
63 >>> point3D() # Default 3D origin
64 (0pt, 0pt, 0pt)
65 >>> point3D(pt(20, -40)) # Add z = pt(0)
66 (20pt, -40pt, 0pt)
67 >>> point3D(mm(30)) # One value defaults to x == y
68 (30mm, 30mm, 0pt)
69 >>> point3D(p(2,3,4,5)) # Trim tuple to 3 coordinates.
70 (2p, 3p, 4p)
71 """
72 if not p: # None or zero.
73 return pt(0, 0, 0) # Undefined 3D point as list.
74
75 if isinstance(p, (list, tuple)):
76 if len(p) > 3:
77 p = p[:3]
78 while len(p) < 3:
79 p += (pt(0),) # Value undefined, add origin as z value.
80 p = tuple(p)
81 else:
82 p = p, p, pt(0)
83
84 return p
85
86def point2D(p=None):
87 """Answers the 2D point from a 2D or 3D point.

Callers 13

__init__Method · 0.90
drawRegistrationMarksFunction · 0.90
drawCropMarksFunction · 0.90
getElementsAtPointMethod · 0.90
_applyAlignmentMethod · 0.90
_applyRotationMethod · 0.90
_restoreRotationMethod · 0.90
_applyScaleMethod · 0.90
_set_sizeMethod · 0.90
point2DFunction · 0.85
pointOffsetFunction · 0.85
point2SFunction · 0.85

Calls 1

ptFunction · 0.85

Tested by

no test coverage detected