point
DmDPoint
双精度点
Source code in dimine_python_sdk\lib\types\point.py
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 341 342 343 344 | |
__add__(other)
向量加法 :param other: 待相加的DmDPoint实例 :return: 相加后的新DmDPoint实例 :raise TypeError: 非DmDPoint实例时抛出
Source code in dimine_python_sdk\lib\types\point.py
82 83 84 85 86 87 88 89 90 91 92 93 | |
__eq__(other)
等于比较运算符 :param other: 待比较的DmDPoint实例 :return: 相等返回True,否则返回False;非DmDPoint实例直接返回False
Source code in dimine_python_sdk\lib\types\point.py
199 200 201 202 203 204 205 206 207 | |
__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
220 221 222 223 224 225 226 227 228 229 | |
__iadd__(other)
向量加法赋值(原地修改) :param other: 待相加的DmDPoint实例 :return: 自身实例(支持链式调用) :raise TypeError: 非DmDPoint实例时抛出
Source code in dimine_python_sdk\lib\types\point.py
138 139 140 141 142 143 144 145 146 147 148 | |
__imul__(scalar)
向量标量乘法赋值(原地修改) :param scalar: 相乘的标量(int/float) :return: 自身实例(支持链式调用) :raise TypeError: 非标量类型时抛出
Source code in dimine_python_sdk\lib\types\point.py
162 163 164 165 166 167 168 169 170 171 172 | |
__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
36 37 38 39 40 41 42 43 | |
__isub__(other)
向量减法赋值(原地修改) :param other: 待相减的DmDPoint实例 :return: 自身实例(支持链式调用) :raise TypeError: 非DmDPoint实例时抛出
Source code in dimine_python_sdk\lib\types\point.py
150 151 152 153 154 155 156 157 158 159 160 | |
__itruediv__(scalar)
向量标量除法赋值(原地修改) :param scalar: 相除的标量(int/float) :return: 自身实例(支持链式调用) :raise TypeError: 非标量类型时抛出 :raise ZeroDivisionError: 标量为0时抛出
Source code in dimine_python_sdk\lib\types\point.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
__mul__(scalar)
向量标量乘法 :param scalar: 相乘的标量(int/float) :return: 相乘后的新DmDPoint实例 :raise TypeError: 非标量类型时抛出
Source code in dimine_python_sdk\lib\types\point.py
108 109 110 111 112 113 114 115 116 117 118 119 | |
__ne__(other)
不等于比较运算符 :param other: 待比较的DmDPoint实例 :return: 不相等返回True,否则返回False;非DmDPoint实例直接返回True
Source code in dimine_python_sdk\lib\types\point.py
209 210 211 212 213 214 215 216 217 | |
__neg__()
负号运算符(取反向量) :return: 取反后的新DmDPoint实例
Source code in dimine_python_sdk\lib\types\point.py
190 191 192 193 194 195 196 197 | |
__repr__()
字符串表示 :return: 向量的标准字符串表示
Source code in dimine_python_sdk\lib\types\point.py
332 333 334 335 336 337 | |
__str__()
打印字符串,与__repr__保持一致,确保输出格式统一 :return: 向量的打印字符串表示
Source code in dimine_python_sdk\lib\types\point.py
339 340 341 342 343 344 | |
__sub__(other)
向量减法 :param other: 待相减的DmDPoint实例 :return: 相减后的新DmDPoint实例 :raise TypeError: 非DmDPoint实例时抛出
Source code in dimine_python_sdk\lib\types\point.py
95 96 97 98 99 100 101 102 103 104 105 106 | |
__truediv__(scalar)
向量标量除法 :param scalar: 相除的标量(int/float) :return: 相除后的新DmDPoint实例 :raise TypeError: 非标量类型时抛出 :raise ZeroDivisionError: 标量为0时抛出
Source code in dimine_python_sdk\lib\types\point.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
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
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
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
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
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
231 232 233 234 235 236 237 238 239 240 241 242 243 | |
norm()
计算向量的模长(长度) :return: 向量模长结果(float)
example:
pt = DmDPoint(3, 4, 0)
print(pt.norm())
Source code in dimine_python_sdk\lib\types\point.py
285 286 287 288 289 290 291 292 293 294 295 296 | |
normalize()
向量归一化(原地修改,转为单位向量) :return: 自身实例
example:
pt = DmDPoint(3, 4, 0)
pt.normalize()
print(pt)
Source code in dimine_python_sdk\lib\types\point.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
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
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
DmDbPoint
点实体
Source code in dimine_python_sdk\lib\types\point.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | |
__init__()
构造函数,初始化数据库点对象
Source code in dimine_python_sdk\lib\types\point.py
423 424 425 | |
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
427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
DmPoints
点集类
Source code in dimine_python_sdk\lib\types\point.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
__init__()
构造函数:初始化点集合对象 :return: None
Source code in dimine_python_sdk\lib\types\point.py
350 351 352 353 354 355 | |
__repr__()
字符串表示(直接调用源端实现,包含点数量和坐标) :return: 点集合的标准字符串表示
Source code in dimine_python_sdk\lib\types\point.py
403 404 405 406 407 408 | |
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
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
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
371 372 373 374 375 376 377 378 379 380 381 382 383 | |
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
357 358 359 360 361 362 363 364 365 366 367 368 369 | |
Point
二次封装Point类
Source code in dimine_python_sdk\lib\types\point.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
__init__(a=0)
构造函数 :param a: 初始化x分量的值,默认0
Source code in dimine_python_sdk\lib\types\point.py
10 11 12 13 14 15 | |
get()
获取x分量的值 :return: x分量的整数值
Source code in dimine_python_sdk\lib\types\point.py
18 19 20 21 22 23 | |
set(a)
设置x分量的值 :param a: 新的x分量整数值
Source code in dimine_python_sdk\lib\types\point.py
25 26 27 28 29 30 | |