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

Function pointOffset

Lib/pagebot/toolbox/units.py:100–127  ·  view source on GitHub ↗

Answers a new 3D point, shifted by offset. NOTE: generally elements will be Unit instances. >>> pointOffset(pt(20, 30, 10), 12) (32pt, 42pt, 22pt) >>> pointOffset(p(20, 30, 40), pt(2, 3, 4)) (20p2, 30p3, 40p4) >>> pointOffset(inch(12, 13), p(10)) (13.67", 14.67", 120pt)

(point, offset)

Source from the content-addressed store, hash-verified

98 return point3D(p)[:2]
99
100def pointOffset(point, offset):
101 """Answers a new 3D point, shifted by offset.
102
103 NOTE: generally elements will be Unit instances.
104
105 >>> pointOffset(pt(20, 30, 10), 12)
106 (32pt, 42pt, 22pt)
107 >>> pointOffset(p(20, 30, 40), pt(2, 3, 4))
108 (20p2, 30p3, 40p4)
109 >>> pointOffset(inch(12, 13), p(10))
110 (13.67", 14.67", 120pt)
111 >>> pointOffset(mm(12, 13), mm(100)) # Adding z = pt(0)
112 (112mm, 113mm, 283.46pt)
113 >>> pointOffset(mm(12, 13, 14), mm(100))
114 (112mm, 113mm, 114mm)
115 >>> pointOffset(pt(10, 20, 30), None) # None is interpreted as offset == 0
116 (10pt, 20pt, 30pt)
117 """
118 if not offset:
119 offset = pt(0, 0, 0)
120
121 if not isinstance(offset, (tuple, list)):
122 offset = (offset, offset, offset)
123
124 point = point3D(point)
125 offset = point3D(offset)
126 assert isinstance(point, (tuple, list))
127 return point[0] + offset[0], point[1] + offset[1], point[2] + offset[2]
128
129def point2S(p):
130 """Answers the point as string of units. Ignores the `z`-value if it

Callers 15

buildMethod · 0.90
build_indsMethod · 0.90
getPositionMethod · 0.90
build_indsMethod · 0.90
buildMethod · 0.90
build_indsMethod · 0.90
buildMethod · 0.90
build_indsMethod · 0.90
buildMethod · 0.90
buildMethod · 0.90
build_htmlMethod · 0.90
buildMethod · 0.90

Calls 2

ptFunction · 0.85
point3DFunction · 0.85

Tested by

no test coverage detected