English 中文(简体)
在Barycentric 分区之后,对所有子公司进行vert
原标题:Find the vertices of all the sub-simplexes following Barycentric subdivision

我有一套K层面标准病媒,而(K-1)-Simplex则对这些病媒作了界定。 我想将这一简单因素分成几个小节,这些小节将最初的简单轴线分为Barycentric子。

例如,在K = 3时,简单x的三vert分别为[1,00]、[0,1,0]和[0,1]。 如果你用 b子子子子子把 this子 sub在est子里,那么你可以做到如下:

  1. Find the mid point of each edge: [1/2, 1/2, 0], [1/2, 0, 1/2],[0, 1/2, 1/2]
  2. Find the barycentric point: [1/3, 1/3, 1/3]

以下清单提供了每一次小节的所有vert点,这些小节将原来的简单X分开:

  1. [[[1,0,0], [1/2, 1/2, 0] [1/3, 1/3, 1/3]]]
  2. [[[1,0,0], [1/2, 0, 1/2] [1/3, 1/3, 1/3]]]
  3. [[[0,1,0], [1/2, 1/2, 0] [1/3, 1/3, 1/3]]]
  4. [[[0,1,0], [0, 1/2, 1/2] [1/3, 1/3, 1/3]]]
  5. [[[0,0,1], [1/2, 0 ,1/2] [1/3, 1/3, 1/3]]]
  6. [[[0,0,1], [0, 1/2, 1/2] [1/3, 1/3, 1/3]]]

在较低层面,这是一项容易完成的任务,然而,我想写出一种功能(通常是在平时,尽管我很灵活),它利用了原简单轴的vert和分裂程度,并将每一次简练清单清单及其vert弄。

我试图开发一个能够解决这一问题的算法,然而,我却不抱逻辑。 每个次级项目将包含对(K-1)层面(例如,在此情况下是一点)、对面和表面的垂直。 因此,我尝试了一种综合方法,但不能将其延伸到能够编入职能的N级。

Is anyone aware of a relevant package (or mathematical software?) that can help answer this question, or on how to write the logic into a python function.

问题回答

You can try the following:

from itertools import permutations
import numpy as np
from sympy import Rational

k = 2 #dimension of the simplex

subdivision = []
for p in permutations(range(k+1)):
    n = len(p)
    fracs = np.array([Rational(1, i) for i in range(1, n+1)]).reshape(-1, 1)
    simplex = np.where(np.tile(p, (n, 1)) <= np.c_[:n], fracs, 0)
    subdivision.append(simplex)

for s in subdivision:
    print(*s)

它规定:

[1 0 0] [1/2 1/2 0] [1/3 1/3 1/3]
[1 0 0] [1/2 0 1/2] [1/3 1/3 1/3]
[0 1 0] [1/2 1/2 0] [1/3 1/3 1/3]
[0 0 1] [1/2 0 1/2] [1/3 1/3 1/3]
[0 1 0] [0 1/2 1/2] [1/3 1/3 1/3]
[0 0 1] [0 1/2 1/2] [1/3 1/3 1/3]

该法典将适用于任何单位,但既然一千imp(k+1)的血压子分层已经! 问题k的简单化,并不现实地将它们归为大的k价值。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签