point
DmDPoint
双精度点
Source code in dimine_python_sdk\lib\types\point.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
__add__(other)
向量加法 :param other: 待相加的DmDPoint实例 :return: 相加后的新DmDPoint实例 :raise TypeError: 非DmDPoint实例时抛出
Source code in dimine_python_sdk\lib\types\point.py
78 79 80 81 82 83 84 85 86 87 88 89 | |
__eq__(other)
等于比较运算符 :param other: 待比较的DmDPoint实例 :return: 相等返回True,否则返回False;非DmDPoint实例直接返回False
Source code in dimine_python_sdk\lib\types\point.py
195 196 197 198 199 200 201 202 203 | |
__getitem__(idx)
索引访问分量(0=x,1=y,2=z) :param idx: 索引值(仅支持0/1/2) :return: 对应索引的分量值(float) :raise IndexError: 索引非整数/超出0-2范围时抛出
Source code in dimine_python_sdk\lib\types\point.py
216 217 218 219 220 221 222 223 224 225 | |
__iadd__(other)
向量加法赋值(原地修改) :param other: 待相加的DmDPoint实例 :return: 自身实例(支持链式调用) :raise TypeError: 非DmDPoint实例时抛出
Source code in dimine_python_sdk\lib\types\point.py
134 135 136 137 138 139 140 141 142 143 144 | |
__imul__(scalar)
向量标量乘法赋值(原地修改) :param scalar: 相乘的标量(int/float) :return: 自身实例(支持链式调用) :raise TypeError: 非标量类型时抛出
Source code in dimine_python_sdk\lib\types\point.py
158 159 160 161 162 163 164 165 166 167 168 | |
__init__(x=0.0, y=0.0, z=0.0)
构造函数 :param x: 向量x分量,默认0.0 :param y: 向量y分量,默认0.0 :param z: 向量z分量,默认0.0
Source code in dimine_python_sdk\lib\types\point.py
32 33 34 35 36 37 38 39 | |
__isub__(other)
向量减法赋值(原地修改) :param other: 待相减的DmDPoint实例 :return: 自身实例(支持链式调用) :raise TypeError: 非DmDPoint实例时抛出
Source code in dimine_python_sdk\lib\types\point.py
146 147 148 149 150 151 152 153 154 155 156 | |
__itruediv__(scalar)
向量标量除法赋值(原地修改) :param scalar: 相除的标量(int/float) :return: 自身实例(支持链式调用) :raise TypeError: 非标量类型时抛出 :raise ZeroDivisionError: 标量为0时抛出
Source code in dimine_python_sdk\lib\types\point.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
__mul__(scalar)
向量标量乘法 :param scalar: 相乘的标量(int/float) :return: 相乘后的新DmDPoint实例 :raise TypeError: 非标量类型时抛出
Source code in dimine_python_sdk\lib\types\point.py
104 105 106 107 108 109 110 111 112 113 114 115 | |
__ne__(other)
不等于比较运算符 :param other: 待比较的DmDPoint实例 :return: 不相等返回True,否则返回False;非DmDPoint实例直接返回True
Source code in dimine_python_sdk\lib\types\point.py
205 206 207 208 209 210 211 212 213 | |
__neg__()
负号运算符(取反向量) :return: 取反后的新DmDPoint实例
Source code in dimine_python_sdk\lib\types\point.py
186 187 188 189 190 191 192 193 | |
__repr__()
字符串表示 :return: 向量的标准字符串表示
Source code in dimine_python_sdk\lib\types\point.py
328 329 330 331 332 333 | |
__str__()
打印字符串,与__repr__保持一致,确保输出格式统一 :return: 向量的打印字符串表示
Source code in dimine_python_sdk\lib\types\point.py
335 336 337 338 339 340 | |
__sub__(other)
向量减法 :param other: 待相减的DmDPoint实例 :return: 相减后的新DmDPoint实例 :raise TypeError: 非DmDPoint实例时抛出
Source code in dimine_python_sdk\lib\types\point.py
91 92 93 94 95 96 97 98 99 100 101 102 | |
__truediv__(scalar)
向量标量除法 :param scalar: 相除的标量(int/float) :return: 相除后的新DmDPoint实例 :raise TypeError: 非标量类型时抛出 :raise ZeroDivisionError: 标量为0时抛出
Source code in dimine_python_sdk\lib\types\point.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
cross_product(other)
计算两个向量的叉积(向量积) :param other: 待计算叉积的DmDPoint实例 :return: 叉积结果的新DmDPoint实例 :raise TypeError: 非DmDPoint实例时抛出
example:
pt1 = DmDPoint(1, 2, 3)
pt2 = DmDPoint(4, 5, 6)
cross = pt1.cross_product(pt2)
print(cross)
Source code in dimine_python_sdk\lib\types\point.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
dot_product(other)
计算两个向量的点积(数量积) :param other: 待计算点积的DmDPoint实例 :return: 点积结果(float) :raise TypeError: 非DmDPoint实例时抛出
example:
pt1 = DmDPoint(1, 2, 3)
pt2 = DmDPoint(4, 5, 6)
dot = pt1.dot_product(pt2)
print(dot)
Source code in dimine_python_sdk\lib\types\point.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
is_zero_length(tol=1e-10)
判断是否为零向量(考虑浮点精度误差) :param tol: 浮点容差阈值,默认1e-10(值越小精度要求越高) :return: 向量长度接近0返回True,否则返回False
example:
pt = DmDPoint(0, 0, 0)
print(pt.is_zero_length())
Source code in dimine_python_sdk\lib\types\point.py
227 228 229 230 231 232 233 234 235 236 237 238 239 | |
norm()
计算向量的模长(长度) :return: 向量模长结果(float)
example:
pt = DmDPoint(3, 4, 0)
print(pt.norm())
Source code in dimine_python_sdk\lib\types\point.py
281 282 283 284 285 286 287 288 289 290 291 292 | |
normalize()
向量归一化(原地修改,转为单位向量) :return: 自身实例
example:
pt = DmDPoint(3, 4, 0)
pt.normalize()
print(pt)
Source code in dimine_python_sdk\lib\types\point.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
set(x, y, z)
一次性设置向量x/y/z分量(原地修改) :param x: 新的x分量值(float) :param y: 新的y分量值(float) :param z: 新的z分量值(float) :return: 自身实例(支持链式调用)
example:
pt = DmDPoint()
pt.set(1, 2, 3)
print(pt) # 输出: (1.0, 2.0, 3.0)
Source code in dimine_python_sdk\lib\types\point.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
DmDbPoint
点实体
Source code in dimine_python_sdk\lib\types\point.py
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 | |
__init__()
构造函数,初始化数据库点对象
Source code in dimine_python_sdk\lib\types\point.py
668 669 670 | |
get_graph_data()
获取该点的图形数据(坐标信息) :return: 点的坐标(DmDPoint实例)
example:
if entity.get_type() == ETT_POINT:
graph_data = entity.get_graph_data()
print(graph_data)
Source code in dimine_python_sdk\lib\types\point.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 | |
DmPoints
点集类
Source code in dimine_python_sdk\lib\types\point.py
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 | |
__init__()
构造函数:初始化点集合对象 :return: None
Source code in dimine_python_sdk\lib\types\point.py
595 596 597 598 599 600 | |
__repr__()
字符串表示(直接调用源端实现,包含点数量和坐标) :return: 点集合的标准字符串表示
Source code in dimine_python_sdk\lib\types\point.py
648 649 650 651 652 653 | |
get_point_data_list()
获取所有点的坐标数据 :return: 点列表,每个元素为DmDPoint实例
example:
points = DmPoints()
points.insert_point(DmDPoint(1, 2, 3), 0)
points.insert_point(DmDPoint(4, 5, 6), 1)
point_list = points.get_point_data_list()
for point in point_list:
print(point)
Source code in dimine_python_sdk\lib\types\point.py
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | |
insert_next_point(point)
插入下一个点,自动分配ID :param point: 待插入的点(DmDPoint实例) :return: 自动分配的点索引(整数)
example:
points = DmPoints()
point_id = points.insert_next_point(DmDPoint(1, 2, 3))
Source code in dimine_python_sdk\lib\types\point.py
616 617 618 619 620 621 622 623 624 625 626 627 628 | |
insert_point(point, point_id)
插入一个点并指定ID,ID不连续则会在中间插入[0,0,0] :param point: 待插入的点(DmDPoint实例) :param point_id: 点的唯一ID(整数)
example:
points = DmPoints()
points.insert_point(DmDPoint(1, 2, 3), 0)
Source code in dimine_python_sdk\lib\types\point.py
602 603 604 605 606 607 608 609 610 611 612 613 614 | |
Point
二次封装Point类
Source code in dimine_python_sdk\lib\types\point.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
__init__(a=0)
构造函数 :param a: 初始化x分量的值,默认0
Source code in dimine_python_sdk\lib\types\point.py
6 7 8 9 10 11 | |
get()
获取x分量的值 :return: x分量的整数值
Source code in dimine_python_sdk\lib\types\point.py
14 15 16 17 18 19 | |
set(a)
设置x分量的值 :param a: 新的x分量整数值
Source code in dimine_python_sdk\lib\types\point.py
21 22 23 24 25 26 | |