[英]Intersection of infinite volumes of any dimension
我需要代碼/文本/谷歌關鍵字/其他資源來實現這個類。 速度無關緊要。 它應該適用於任何數量的維度。
class InfiniteVolume: # such as a point, line, plane, volume, 4d-volume
def __init__(self, points): # two points for line, three points for plane, etc.
self.points = points
assert all(len(p)==len(points[0]) for p in points)
def vdim(self): # Dimensions of the volume. For example 2.
return len(self.points)-1
def wdim(self): # Dimensions of the world. For example 3.
return len(self.points[0])
def __contains__(self, point):
# ???
def intersect(self, other):
assert self.wdim() == other.wdim()
# ???
您試圖表示嵌入在M維空間中的N維空間。 例如,(N = 2,M = 3)是三維“世界”中的平面。
如果您願意,可以實現一組定義的點,但表示這樣一個子空間的自然方式是使用一組線性方程或基礎向量,因此這應該是底層實現。 如果使用基矢量,則有N個。 如果使用方程式,則每個方程式將維數減少1,因此存在MN。
要找到兩個這樣的子空間的交集,您只需將它們的組合並減少(到一組線性獨立的向量或方程)。 交點的維數可以是從零到N的任何值。
這些技術很簡單,眾所周知,屬於線性代數的標題。
編輯:
我認為處理基礎向量最容易。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.