mirror of
https://github.com/SikongJueluo/Mini-Nav.git
synced 2026-07-12 20:15:31 +08:00
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from dataclasses import dataclass
|
||
|
||
import numpy as np
|
||
|
||
|
||
@dataclass
|
||
class RoomNode:
|
||
room_id: str # 例如: "room_A"
|
||
|
||
# 范围:不用复杂的 Polygon,用一个中心点+半径,或者简单的 3D BBox 足够了
|
||
center: np.ndarray # [x, y, z]
|
||
bbox_extent: np.ndarray # [dx, dy, dz] 用于快速判断一个点在不在房间里
|
||
|
||
def __post_init__(self):
|
||
self.center = np.asarray(self.center, dtype=np.float32)
|
||
self.bbox_extent = np.asarray(self.bbox_extent, dtype=np.float32)
|
||
|
||
if self.center.shape != (3,):
|
||
raise ValueError(f"center must have shape (3,), got {self.center.shape}")
|
||
|
||
if self.bbox_extent.shape != (3,):
|
||
raise ValueError(f"bbox_extent must have shape (3,), got {self.bbox_extent.shape}")
|
||
|
||
if not np.all(np.isfinite(self.center)):
|
||
raise ValueError("center must contain only finite values")
|
||
|
||
if not np.all(np.isfinite(self.bbox_extent)):
|
||
raise ValueError("bbox_extent must contain only finite values")
|
||
|
||
if np.any(self.bbox_extent < 0):
|
||
raise ValueError("bbox_extent must be non-negative") |