- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在处理许多 3D 平面并为以下情况寻找最小二乘法解决方案。
IF I am having many number of 3D planes knowing only one point and thenormal vector (for eg. O1 and N1), and all those planes intersect eachother and make nearly very close 3d lines, then how to compute theleast square adjusted one single 3d line to represent all thoseintersections.
为了清楚起见,我插入了一张图。
因为我想用 c++ 做这个,所以我也使用 c++ 标签。
最佳答案
完全未经测试。
如果您从交叉点获取线的方向并得到 Principle Component 会怎么样?
这将为您提供他们前进的方向。然后使用该方向和任意点创建一个平面,将平面相交计算中的所有点投影到平面上,并找到这些投影点的平均点。
使用该平均点和主成分来定义您的线。
有点像...
class Plane
{
public:
Vector3 Point;
Vector3 Normal;
Line Intersect (const Plane &other);
Vector3 Project (const Vector3 &point);
}
class Line
{
public:
Vector3 Point;
Vector3 Direction;
Line (Vector3 point, Vector3 dir);
};
Vector3 PrincipleComponent (const std::vector<Line> &lines)
{
//You could use the covariance matrix to get this but I will try the interative method on wikipedia.
Vector3 p(1,2,3); //a random vector?
static const int c = 10;
for (int i = 0; i < c; ++i)
{
Vector3 t;
for (auto i = lines.begin(); i != lines.end (); ++i)
{
t = t + ((*i).Direction.Dot (p)) * (*i).Direction;
}
t.Normalize();
p = t;
}
return p;
}
int main ()
{
std::vector<Line> LinesFromPlaneIntersections;
Vector3 direction = PrincipleComponent (LinesFromPlaneIntersections);
Plane projplane;
projplane.Normal = direction;
projplane.Point = LinesFromPlaneIntersections[0].Point;
Vector3 meanpoint;
for (auto i = LinesFromPlaneIntersections.begin(); i != LinesFromPlaneIntersections.end (); ++i)
{
meanpoint += projplane.Project ((*i).Point);
}
meanpoint /= LinesFromPlaneIntersections.size ();
Line result (meanpoint,direction);
}
关于c++ - 通过与多个 3D 平面相交获得最小二乘调整的单线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15410788/
此代码似乎在启用优化的广泛使用的编译器上中断,尽管它在 Visual Studio 中运行良好。 struct foo { foo(int a) { s[0] = '0'+a%10;s[1]
我想要一个图表,其中有一个单线箭头,如下所示: 1 2 3 4 5 或者像这样(其中/假设是一个箭头:)): \/ -----------------
我正在为 Java 编写自定义规则。有两个 Tree.KIND 实例(STRING_LITERAL 和 ASSIGNMENT)需要捕获。有一个特定的行,字符串文字和赋值的逻辑都会引发问题。但 Sona
Rosettacode.org 在 Ruby 中有这个出色的单行 FizzBuzz 解决方案。 1.upto(100){|n|puts'FizzBuzz '[i=n**4%-15,i+13]||n
很多时候我使用了这个命令,它在当前目录打开了一个临时的 HTTP 服务器: python3 -m http.server 现在我需要接收文件,有没有打开ftp服务器的一行命令? 我只是在寻找一个命令行
相关主题 std::unique_ptr, deleters and the Win32 API 要将 Win32 句柄用作 RAII,我可以使用以下行 std::unique_ptr::type,
我认为必须有一个单行 Guava 解决方案来将一个不可变列表转换为另一个不可变列表,但我找不到它。假设我们有以下对象: ImmutableList input = ImmutableList.of("
我有以下 Highcharts ( http://www.highcharts.com ) 散点图。请注意,轴从 -10 开始,到 10 停止,中间为 0。我希望每条 0 线的宽度或颜色都与其他线不同
我有一个项目需要将一个视频文件与另一个音频文件合并。预期的输出是一个视频文件,其中包含来自实际视频的音频和合并后的音频文件。输出视频文件的长度将与实际视频文件的大小相同。 是否有单行 FFMPEG 命
我在 python3 类中有 2 个列表: self.keys = ["a","b","c","d"] self.values = [1,2,3,4] len(self.keys) == len(se
我有一个不同长度的数组列表,我想将它们组合成一个最大维度的矩阵,并在末尾填充零。例如(伪代码): combine( [1,2,3], [4,5]) [[1,2,3],[4,5,0]] 这是我目前的解决
例如,给定 i=5 和 n=8,我想生成 [0;0;0;0;1;0; 0;0]。具体来说,我想生成向量 v 以便: v = zeros(n,1); v(i) = 1; 有没有一种(合理的)方法可以在一
我是一名优秀的程序员,十分优秀!